Expression Builder: AND OR

You found a bug or have any issues? Please post them here!
Post Reply
Thijmen
Posts: 92
Joined: 16 Jul 2019 20:19
Expression Builder: AND OR

Post 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?
Attachments
2022-05-03_21h41_57.png
2022-05-03_21h41_57.png (6.16 KiB) Viewed 1604 times
Thijmen
Posts: 92
Joined: 16 Jul 2019 20:19
Re: Expression Builder: AND OR

Post by Thijmen »

Also when pressing OK and then opening the filter again, it removed my OR statement.
Attachments
2022-05-03_21h44_54.png
2022-05-03_21h44_54.png (5.14 KiB) Viewed 1603 times
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Expression Builder: AND OR

Post 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.
Image
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.
Thijmen
Posts: 92
Joined: 16 Jul 2019 20:19
Re: Expression Builder: AND OR

Post 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'))
Attachments
2022-05-04_12h43_12.png
2022-05-04_12h43_12.png (6.52 KiB) Viewed 1591 times
Thijmen
Posts: 92
Joined: 16 Jul 2019 20:19
Re: Expression Builder: AND OR

Post 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!
Attachments
2022-05-04_12h44_55.png
2022-05-04_12h44_55.png (6.11 KiB) Viewed 1591 times
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Expression Builder: AND OR

Post 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.

Post Reply