# Linked input: 2 datasets

**URL:** <https://talk.observablehq.com/t/linked-input-2-datasets/7872>\
**Category:** Help\
**Created:** [April 21, 2023, 7:08pm UTC](https://talk.observablehq.com/t/linked-input-2-datasets/7872 "2023-04-21T19:08:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [April 21, 2023, 7:08pm UTC](https://talk.observablehq.com/t/linked-input-2-datasets/7872/1 "2023-04-21T19:08:28Z")

</div>

I am working on a POC that has 2 datasets that are needed to drive 2 different charts. I have 2 files that are representative the of the datasets (1) bill - state and bill identifier and (2) bill\_vote - state and bill identifier & actually votes cast for the bill. (NOTE: the reason for the separation is that the bill\_vote dataset will grow exponentially)

What has been built so far is a view that allows the drill down input of the bill based on state & year & signed by governor filters.

What I am trying to do is tie the **Select bill** input to the vote\_bill dataset so when a bill is selected it will select the bill identifier for the bill\_vote dataset, eliminating the need for the redundant **Select bill vote** input

Below is the link to the chart - any help is appreciated in advance,

Thanks - Mike

> **[test\_linked\_data](https://observablehq.com/d/10812c7962a55c1b)**

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [April 22, 2023, 8:57am UTC](https://talk.observablehq.com/t/linked-input-2-datasets/7872/2 "2023-04-22T08:57:30Z")

</div>

You’d filter your dataset by the bill identifier (both .id and .identifier will work):

```auto
bill_vote.filter(d => d.id === bill_select[0].id)

```

But it appears that you have minimal overlap between the two. Vote data only seems to be available for 30 bills:

```auto
{
  const key = d => d.id;
  const a = new Set(bill.map(key));
  return [...new Set(bill_vote.map(key))].filter(d => a.has(d));
}

```

---

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [April 24, 2023, 5:34pm UTC](https://talk.observablehq.com/t/linked-input-2-datasets/7872/3 "2023-04-24T17:34:44Z")

</div>

> [@mootari](#):
>
> `bill_vote.filter(d => d.id === bill_select[0].id)`

Thanks - this works! - I know the datasets are not in sync - I am refactoring a bug my queries
