# problem in filtering dataset via user dropdown choice 

**URL:** <https://forum.wixstudio.com/t/problem-in-filtering-dataset-via-user-dropdown-choice/23367>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [April 5, 2019, 1:18pm UTC](https://forum.wixstudio.com/t/problem-in-filtering-dataset-via-user-dropdown-choice/23367 "2019-04-05T13:18:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![srom123](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@srom123](https://forum.wixstudio.com/u/srom123)\
**Post date:** [April 5, 2019, 1:18pm UTC](https://forum.wixstudio.com/t/problem-in-filtering-dataset-via-user-dropdown-choice/23367/1 "2019-04-05T13:18:31Z")

</div>

i have a dropdown which has a number of options, and a table which is below that is connected to a dataset which will show products. i am trying to make it so when the user selects the value then presses the button it will then display the filtered results in the table.

the value i want to filter on, is a reference field called ‘modelSuited’ in my database. this is the following code snippet that i am working with at the minute:

when the button is pressed:

export function button3\_click(event) {  
//Add your code for this event here:  
//filter($w(“#ModelDropDown”).value)  
db();  
$w(“#productTable”).show();  
}

**function** db (){  
// **var** model = $w(“#ModelDropDown”);  
$w(“#dataset1”).setFilter( wixData.filter() .contains(‘modelSuited’, $w(“#ModelDropDown”)))  
.then( (results) =\> {  
console.log(“Dataset is now filtered”);  
**let** items = results.item; // This is now the filtered items  
$w(“#productTable”).rows = items;  
} ) . **catch** ( (err) =\> {  
console.log(err);  
} );  
}

when i then press the button on preview mode i get the following error:

Error: Failed to build a filter. Invalid .contains parameter value [Object]. .contains parameter must be a String…

i have also tried .eq/.hasSome to try and get it to work but doesnt seem to be playing ball.

i can change the query to pass in a “string” e.g hard code it for test purposes and get the following:

Dataset is now filtered  
TypeError: Cannot read property ‘item’ of undefined

if anyone could help me out the achieve filtering on the reference field to match the product with the model, that would be great. thanks

#dropdown #filter #database #query #queryonvalue

---

<div class="post-metadata">

**Author:** ![srom123](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@srom123](https://forum.wixstudio.com/u/srom123)\
**Post date:** [April 5, 2019, 6:16pm UTC](https://forum.wixstudio.com/t/problem-in-filtering-dataset-via-user-dropdown-choice/23367/2 "2019-04-05T18:16:11Z")

</div>

update\* i can make it work using the title field instead of reference field. so seems to be a problem with the reference field.
