Page 1 of 1
Expression Builder: AND OR
Posted: 03 May 2022 21:44
by Thijmen
Hi,
I am trying to create the following:
I want to filter on [Rating Value > 20] AND ( [Filename Contains Test] OR [Artist contains Test])
See screenshot (at least, I think that this should be done like this - I may be wrong).
When I press the Text tab, the text shows me this:
[Rating] > '20' And Contains([Filename], 'Test') And Contains([Artist], 'Test')
However, this seems wrong to me! The expression should check on Artist OR Filename, not AND!
Is this a bug that I run into, or is this my mistake?
Re: Expression Builder: AND OR
Posted: 03 May 2022 21:45
by Thijmen
Also when pressing OK and then opening the filter again, it removed my OR statement.
Re: Expression Builder: AND OR
Posted: 03 May 2022 23:05
by radio42
I think your mistake is, that all items (criteria) on the same level use the same logical group condition.
Ie. you might want to move the OR condition one level to the left. Meaning you need to add the OR condition to the previous root node.

In your case you have defined multiple groups, which infact doesn’t make much sense, as each group only containes one single condition.
A logical operator only makes sense, when you have at least two conditions in one group.
Re: Expression Builder: AND OR
Posted: 04 May 2022 12:44
by Thijmen
Hi Bernd,
Unfortunately, that does not help.
It transforms the image to the following expression:
[Rating] > '20' And Contains([Filename], 'Armin van Buuren') And Contains([Artist], 'Armin van Buuren')
Whereas it should create something like this:
[Rating] > '20' And (Contains([Filename], 'Armin van Buuren') OR Contains([Artist], 'Armin van Buuren'))
Re: Expression Builder: AND OR
Posted: 04 May 2022 12:46
by Thijmen
I think the UI of the Expression Builder is a bit misleading (or I got it twisted in my head).
When I enter this text, it creates the following expression.
[Rating] > '20' And (Contains([Filename], 'Armin van Buuren') Or Contains([Artist], 'Armin van Buuren'))
To me, it looks like Rating > 20 OR Filename AND Artist contains. Might be me though!
Can you confirm this is correct now? This expression does what I want though, thanks!
Re: Expression Builder: AND OR
Posted: 04 May 2022 13:38
by radio42
This is correct now - look at the brackets, which indicate the group. And this is exactly how I mean it in my text.
Any group only makes sense and as such is evaluated, if at least 2 conditions are included.