# Dataset Filtering on Dropdowns

**URL:** <https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 22, 2022, 12:29pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052 "2022-06-22T12:29:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casey\_Roman](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@Casey\_Roman](https://forum.inductiveautomation.com/u/Casey_Roman)\
**Post date:** [June 22, 2022, 12:29pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/1 "2022-06-22T12:29:31Z")

</div>

I am using a memory tag data set to reference options in a dropdown on my perspective app. I want to have a second dropdown that references all options that have the same attribute based on the first dropdowns selection.

Example: Dataset -

Colorado, Denver  
Colorado, Grand Junction  
Nevada, Las Vegas  
California, L.A.  
Virginia, Lexington

If in the first dropdown selection I choose “Colorado”, I want the second dropdown to display options “Denver” and “Grand Junction”.

I currently have this code in the second dropdown:

```
tabList = []
for row in range(value.getRowCount()):
	tabList.append(self.getSibling("Zone_Select_Drop").props.value)
return tabList

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 22, 2022, 12:50pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/2 "2022-06-22T12:50:10Z")

</div>

You need to actually loop through the data set. This code will add the same value for however many rows are in the value dataset.

Something more like

```auto
tabList = []

selectedValue = self.getSibling("Zone_Select_Drop").props.value

for row in range(value.getRowCount()):
    if value.getValueAt(row, 0) == selectedValue:
        tabList.append(value.getValueAt(row, 1)

return tabList

```

That of course can be compressed to a comprehension, but it should get you close.

---

<div class="post-metadata">

**Author:** ![Casey\_Roman](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@Casey\_Roman](https://forum.inductiveautomation.com/u/Casey_Roman)\
**Post date:** [June 22, 2022, 1:56pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/3 "2022-06-22T13:56:50Z")

</div>

> [@lrose](#):
>
> ```auto
> tabList = []
> 
> selectedValue = self.getSibling("Zone_Select_Drop").props.value
> 
> for row in range(value.getRowCount()):
> if value.getValueAt(row, 0) == selectedValue:
> tabList.append(value.getValueAt(row, 1)
> 
> return tabList
> 
> ```

Why am I getting an Error on the return?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/07b3931355773a16e7b1962a547f09230946e98d.png)

---

<div class="post-metadata">

**Author:** ![Casey\_Roman](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@Casey\_Roman](https://forum.inductiveautomation.com/u/Casey_Roman)\
**Post date:** [June 22, 2022, 1:58pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/4 "2022-06-22T13:58:08Z")

</div>

tooltip saying “no viable alternative at input ‘return’”

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 22, 2022, 2:07pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/5 "2022-06-22T14:07:00Z")

</div>

Check your indentation. It needs to all be either tabs or spaces, and it needs to be at the correct level.

I can see from the screen shot that it looks incorrect. Copy and paste can often mess around with it.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 22, 2022, 2:46pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/6 "2022-06-22T14:46:55Z")

</div>

De-dent lines 14 and 15 one step each.

---

<div class="post-metadata">

**Author:** ![Casey\_Roman](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@Casey\_Roman](https://forum.inductiveautomation.com/u/Casey_Roman)\
**Post date:** [June 22, 2022, 2:54pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/7 "2022-06-22T14:54:21Z")

</div>

Nailed it. Thanks guys!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 10, 2023, 5:28pm UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/8 "2023-01-10T17:28:22Z")

</div>

Split this topic on January 10, 2023, 5:28pm UTC

14 posts were split to a new topic: [Help with data entry form](https://forum.inductiveautomation.com/t/help-with-data-entry-form/68440)

---

<div class="post-metadata">

**Author:** ![hisyam\_agung](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@hisyam\_agung](https://forum.inductiveautomation.com/u/hisyam_agung)\
**Post date:** [December 5, 2023, 7:48am UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/9 "2023-12-05T07:48:10Z")

</div>

I have case like you need for filter second dropdown based on selection of first dropdown, can you share full script?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 5, 2023, 7:53am UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/10 "2023-12-05T07:53:49Z")

</div>

Well... Can you share the full question ?

---

<div class="post-metadata">

**Author:** ![hisyam\_agung](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@hisyam\_agung](https://forum.inductiveautomation.com/u/hisyam_agung)\
**Post date:** [December 5, 2023, 8:07am UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/11 "2023-12-05T08:07:38Z")

</div>

I am using Query to reference option in a dropdown. Same like -Casey\_Roman , I want to have a second dropdown based on the first dropdowns selection:

Detail Table:  
ID | Area | Process Name  
1 | Area 1 | Process 1  
2 | Area 1 | Process 2  
3 | Area 1 | Process 3  
4 | Area 2 | Process 4  
5 | Area 2 | Process 5

First dropdown I choose "Area 1" and second dropdown will display options "Process 1, Process 2, Process 3". Is it possible for using same script like -Casey\_Roman although using query?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 5, 2023, 8:11am UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/12 "2023-12-05T08:11:59Z")

</div>

Use a parameterized named query, and use the first dropdown's value as the parameter to the second dropdown's query. That's it.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/435be3ac5952dc10c15b4305bc559fe46729d0d3.png)  
.

---

<div class="post-metadata">

**Author:** ![hisyam\_agung](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@hisyam\_agung](https://forum.inductiveautomation.com/u/hisyam_agung)\
**Post date:** [December 5, 2023, 8:34am UTC](https://forum.inductiveautomation.com/t/dataset-filtering-on-dropdowns/61052/13 "2023-12-05T08:34:22Z")

</div>

It's so simple more than I though, thankyou very much. I've wasted so much time on this.
