Multiple filters

Hi everyone,

How can I add multiple filters to a dataset, I have tried several ways without any results.

For example, how could a client filter by selecting two dropdown menus, and then filter a database and find items that match both conditions for example:

Selecting:
Favorite color: red
Favorite food: pizza

Would return results of items who have red as favorite color and favorite food as pizza.

Thanks! I appreciate any help I can get.

Hello

here’s some hints you can follow:

  • add your two dropdowns, element to show the output (it can be a repeater, table, text element…), and a button to click to show the output (this step is optional depends on your website and what you think is better, but to make it easier i’ll explain the following steps based on those elements)

  • declare two global variables: filter1–> store value of dropdown1 , filter2–> store value of dropdown2

  • add on change event to the two dropdowns

  • on those events set the values of the filters - here
    - add on button click event

  • inside the event set the filters values to the dataset you have - here

  • show the result in the element

Best
Massa

Hi Massa,

Thank you for the input!

I wanted to do something like this, being able to filter something to get results that match both conditions, something like this:

**I have doubts about how to implement not only two conditions but many conditions, what could I do for the Bold and Italic Part of my code.

export function button14_click(event, $w) {

const Ubic = wixData.filter().contains("ubicacion", $w("#dropdown2").value)
const Voca = wixData.filter().contains("vocacion", $w("#dropdown6").value)

$w("#dataset5").setFilter(Voca && Ubic);
console.log('done');

}

Thank you very much!!!

Hello

you can create one filter for Ubic and Voca and then setting this new filter to the dataset.
Check this answer out : https://www.wix.com/code/home/forum/community-discussion/add-a-filter-to-dataset-but-also-keep-the-previous-filter

Best
Massa

Hello please can you help me? I need your assistance i have set a filter using multiple checkboxes that displays the result in a table. But the prblemis that mobile view of the table is not propper i have tried every thing i know in vain i thing my code is not good that’s the reason. Can you olease help me to figure it out ?

This post is from 2018 and being closed.
Please add a new forum post with a link to refer back to this post instead of bumping up an old thread.

Note that you can alter mobile design in the Wix Mobile Editor.
https://support.wix.com/en/article/about-the-mobile-editor