setFilter Dataset overwrite

Hi I have a dateset which I want to filter with multiple inquiries.

The first filter is directly in dataset :

The second one is implemented from code like :

setFilterKapa =  wixData.filter().between("platze", kapaFrom, kapaTo + 1);
$w('#Saal').setFilter(setFilterKapa);

When I only run the first filter → every think is fine.
When I only run the second → every think is fine.
When I first and then the second → second overwrite the first filter.

Question: How can I run both filters together with a “and-compination” ?

Hi,
Setting a dataset’s filter overrides existing filters that were previously set using the setFilter() function or using the Dataset Settings panel in the Editor. See here .

You need to either set both filters using data binding or using code. When using code you can use and() condition. See here .

I assume by what you are looking at achieving you have a dynamic database on the page, and trying to set the second dataset by both the first database and the coded variable if so as per Aleks answer you need to code both into it. See below;

import wixData from 'wix-data';

$w("#dynamicDataset").onReady(() => {
             let dynamicID = $w("#dynamicDataset").getCurrentItem()._id
             let filter = wixData.filter()
                          .hasSome("column", [dynamicID])
                          .between("platze", kapaFrom, kapaTo + 1);

             $w("#dataset2").setFilter(filter) 
})

Thank you for the answer, if I should code both quiries thats fine for me. But can you pleas answer the question, how can I set a filter to a referenced field with multiple items?

I have two dataset :

  1. Dateset is Location

  1. Dataset is EventType

In Location I have a reference to EventType with multiple selection. Can you please tell me how can I set a filter to Location-> EventType.

For example I will filter all Location with EventType “Sünnet”. Result should be Line 2 in Location ->Kral Event GmbH

As above to query a multi referenced field you need to use hasSome with the field ID inside an array,

So hasSome(‘column’, [id1, id2])

This will return any items with id1 or id2 as the referenced items _id field,