Unable to filter 'ref' field ?!?


I am trying to filter a database based on a Field Type ‘Reference’.

For some reason it is not working and I get the feeling that it is not possible.

Is it possible?

Hi Benny,

Just to make sure - do you want to show content from a Collection on the Website itself while filtering it by a reference field that it contains?


Here is the full case:
My main Collection (Projects) has few fields that are connected by ‘Reference’ to other collections (Type of Material).
All the data is shown is a repeater from the main collection- so far no problems

When I try to add filter to the repeater based on the field in the Collection which is a "Reference’ field (material ) the repeater is filtered but shows no data at all.

Here is the code:

import wixData from ‘wix-data’;

$w.onReady(() => {


export function dropdown1_change(event, $w) {
$w(‘#projectsDS’).setFilter ( wixData.filter()
.eq(‘material’, $w(‘#MaterialDropdown’).value)

. catch (err =>
console.log("problem in search! " + err);

Here is a link to the editor page

According to your Code it seems like there is a Dropdown somewhere that applies a filter, but I can’t find it on the website itself.

Generally speaking you can filter Collection content according to Reference field by using an additional Dataset (w\o writing code. only Data Binding experience).

What you need to do there is:

  1. Adding an extra Dataset that’s connected to the referenced Collection.

  2. Filter the 2nd Dataset according to the Filter that you want to apply.

  3. Add a filter to the original Dataset with the following Filter: “Field” = Your referenced field, “Condition” = “Same as”, “Dataset” = your 2nd Dataset which is already filtered (when setting the filters’ “Field” item to be a referenced field you’ll be able to see that the “Value” title turns into the word “Dataset”).

You can find more info about “how to filter information using reference” here .

Thanks for this
The first issue was due to the fact that I changed the dropdown name but it had no influence on the code itself. In any case I changed it to have the same name.

All your recommendations where done already.

#TypeOfProject - is the page dynamic dataset
projects - is the main data base
#TypeOfMaterial - is the dropdown options

The page is loaded with the filtered information based on the type of project selected.

Now I need to filter the results based on the dropdown value equals to the data in the ‘reference’ field (material) in the projects collection.

I hope this is clear.

Have you tried to apply the filter (that is being fetched from the Dropdown) on top of the Second Dataset ( #TypeOfMaterial ) instead?


Sorry, don’t get what you suggested

According to the Code It seems like your are trying to apply a filter on top of the primary Dataset ( #projectsDS ').

The filter should be applied on the 2nd Dataset ( #TypeOfMaterial ).
If the 1st Dataset is filtered correctly by the 2nd Dataset, then applying a filter on the 2nd Dataset should automagically trigger a correct filter on the Primary Dataset.

In theory you might be right, but…

I made a new page without any filter set.
Connected everything and it doesn’t work.
Have a look

As I played with this for hours I feel that it might be not possible to filter based on a ‘reference’ field

Try using the following Code:

export function searchButton_click() {
let doFilter = wixData.filter()
if ($w(‘#ProjectsDropdown’).value.length) {
doFilter = doFilter.eq(‘ProjectType’, $w(‘#ProjectsDropdown’).value)
if ($w(‘#MaterialDropdown’).value.length) {
doFilter = doFilter.eq(‘type’, $w(‘#MaterialDropdown’).value)
. catch (err => {
console.log("problem in search! " + err);

The code you wrote connects to none “Reference” fields.
You actually use the extra fields I added in order to find a workaround solution.
The 'Reference" fields are:
‘material’ for the #MaterialDropdown
‘project’ for the #ProjectsDropdown