Advance filter criteria order of operations
I'm using advanced filter criteria with the Tables: apply filters action.
This filter works:
columns['Client'] == {{companyname}} && columns['Template Filter Criteria'] == "All"
This filter does not:
columns['Client'] == {{companyname}} && (columns['Template Filter Criteria'] == "All")
Why is that?
We're actually trying to accomplish the following:
columns['Client'] == {{companyname}} && (columns['Template Filter Criteria'] == "All" || columns['Template Filter Criteria'] == {{template-filter-criteria}})
Which fails due to the parenthesis. We're forced to to the following, but it feels bulky:
columns['Client'] == {{companyname}} && columns['Template Filter Criteria'] == "All" || columns['Client'] == {{companyname}} && columns['Template Filter Criteria'] == {{template-filter-criteria}}
Any ideas here?
Answers
-
After testing this more, it appears that this advanced filter criteria does not work:
columns['Client'] == {{companyname}} && columns['Template Filter Criteria'] == "All" || columns['Client'] == {{companyname}} && columns['Template Filter Criteria'] == {{template-filter-criteria}}
The table I want to filter looks something like this:
Client Template Filter Criteria ID ABC Co All adkjsfads ABC Co Type 1 fksdjh ABC Co Type 1 lkjhlk ABC Co Type 2 987987897 123 Inc Type X oioioi 123 Inc Type Y ouyfouyf 123 Inc All 69689986 123 Inc All jkhvkjv When I use the above advanced filter criteria with
{{companyname}} = 123 Inc
and{{template-filter-criteria}} = Type X
, I get 0 rows in the resulting table. However, I would expect to get 3, namely:Client Template Filter Criteria ID 123 Inc Type X oioioi 123 Inc All 69689986 123 Inc All jkhvkjv Can you help me understand what I'm doing wrong here?
0 -
Tom, I suspect your "and" and "or" operators are creating a non intersecting set giving you no matches. The operators are not evaluating in the order you might intend. As you mentioned in another post, the advanced filter does not seem to accept grouping as an operator. So you might try your filter with the two|| first and then the &&. That would likely work with only one && criteria.
I believe for now the easiest way to do what you want is two apply filters and then join the two resulting tables.
0 -
Or apply filter to one condition, and them apply filter to the resulting table for the second condition. That might be easier and more performant.
0 -
Hi @Sean_510793, thanks for the feedback. As you suggested in your first reply, I tried the following advanced filter criteria:
columns['Template Filter Criteria'] == 'All' || columns['Template Filter Criteria'] == {{template-filter-criteria}} && columns['Client'] == {{companyname}}
While this gives me my desired result, it is an unexpected result, since
&&
should take logical precedence over||
. This seems like a bug.Should I be concerned about using this approach given that it gives a desired but unexpected result? My concern would be that a fix goes into place in the future, making my advanced filter criteria produce an undesired, albeit expected result.
0 -
@Tom_944137 you can rely on this behavior. We will not change the behavior of this action version. If we address this in the future we will create a new action version with updated behavior, but leave the existing action alone.
Hope this helps!1