Two conditions for visibility (need some help)

Hi,

I have a list of items with different filters, named “categories” and “level”

I designed two dropdown menus with those filters and only those items should be visible that are true to both filters. I tried to do that with the formula:

IS_EQUAL(CONTAINS(LOWERCASE(repeated.current.fields.categories.stringValue), LOWERCASE(pageVars.filterCategories)),CONTAINS(LOWERCASE(repeated.current.fields.level.stringValue), LOWERCASE(pageVars.filterlevel))

But now those items that are NOT of the category and level show up, because both CONTAINS are false → false and false is equal.

Any help would be very much appreciated

I think you want to “and” the two conditions, not compare them. In other words:

CONTAINS(LOWERCASE(repeated.current.fields.categories.stringValue), LOWERCASE(pageVars.filterCategories)) &&
CONTAINS(LOWERCASE(repeated.current.fields.level.stringValue), LOWERCASE(pageVars.filterlevel))

The && means “AND” and requires that both of your tests be true in order for the item to be visible

1 Like

I think wrapping the "CONTAINS() function in a Not() function would also help.

1 Like

Thank you,
this works perfectly :star_struck:

I don’t think the documentation does a good job of explaining this.

Also, if you want a boolean expression that’s true if condition A or condition B is true, use || (the key just above enter key). You can combine these into very complex expressions if needed. For example, condition_A && (condition_B || condition_C) which will only be true if A is true AND either B or C (or both) are true.

1 Like