BrewQlL Syntax help

Hi,

I need a bit of syntax help.

I do not understand why this report generates results with credit notes before 01-12-2024

— BEGIN BREWW RDE SHARE CODE —
eyJiYXNlX2RhdGFfY29kZSI6ImNyZWRpdF9ub3Rlc19saW5lcyIsImZpZWxkc190b192aWV3IjoiY3JlZGl0X25vdGUubnVtYmVyLCBjcmVkaXRfbm90ZS5jdXN0b21lci5uYW1lLCBjcmVkaXRfbm90ZS5jdXN0b21lci50eXBlLnR5cGUsIHByb2R1Y3QubmFtZSwgcXVhbnRpdHksIHRvdGFsX25ldHRfYW1vdW50LCBjcmVkaXRfbm90ZS5jcmVhdGVkX29uIiwiYnJld3dxbF9maWx0ZXIiOiJjcmVkaXRfbm90ZS5zdGF0dXMgPSBcIkZpbmFsaXNlZFwiIGFuZCBwcm9kdWN0Lm5hbWUgPSBcIkRlcG9zaXQvU3RhdGllZ2VsZCBGdXN0ICgwJSlcIiBvciBwcm9kdWN0Lm5hbWUgPSBcIkRlcG9zaXQvU3RhdGllZ2VsZCBLZWdzIFVuaXRlZCBGdXN0XCIgb3IgcHJvZHVjdC5uYW1lID0gXCJEZXBvc2l0L1N0YXRpZWdlbGQgS0ggRnVzdFwiIGFuZCBjcmVkaXRfbm90ZS5jcmVhdGVkX29uID49IFwiMDEvMTIvMjAyNFwiIn0=
— END BREWW RDE SHARE CODE —

Hmm. Maybe it’s the evaluation order of all those ands and ors

Perhaps try something like this for the product name:

product.name in (“Deposit/Statiegeld Fust (0%)” , “Deposit/Statiegeld Kegs United Fust” , “Deposit/Statiegeld KH Fust” )

Hi Gijs, Thanks for your comment! @jon-kyme2 is correct; you will need to bracket the filter for the product name that uses ‘ors’ after the initial ‘and’. Simply adding brackets here should resolve this; however, Jon’s suggestion of ‘product.name in’ should also work! Let me know if you need any more help. Cheers!

1 Like

Could you provide me with the exact syntax? BrewwQL is throwing me errors when I add brackets

I think I got some smart quotes in there, sorry, try:

product.name in (“Deposit/Statiegeld Fust (0%)”, “Deposit/Statiegeld Kegs United Fust”, “Deposit/Statiegeld KH Fust”)

Yeah, That one doesn’t work, and was asking for Ben’s solution

Or, do what Ben said, put brackets around that string of ors on the product.name:

( product.name = “Deposit/Statiegeld Fust (0%)” or product.name = “Deposit/Statiegeld Kegs United Fust” or product.name = “Deposit/Statiegeld KH Fust” )

Using the in thing would probably make it easier to read and find errors. And change if you need to.

Again not working.

— BEGIN BREWW RDE SHARE CODE —
eyJiYXNlX2RhdGFfY29kZSI6ImNyZWRpdF9ub3Rlc19saW5lcyIsImZpZWxkc190b192aWV3IjoiY3JlZGl0X25vdGUubnVtYmVyLCBjcmVkaXRfbm90ZS5jdXN0b21lci5uYW1lLCBjcmVkaXRfbm90ZS5jdXN0b21lci50eXBlLnR5cGUsIHByb2R1Y3QubmFtZSwgcXVhbnRpdHksIHRvdGFsX25ldHRfYW1vdW50LCBjcmVkaXRfbm90ZS5jcmVhdGVkX29uIiwiYnJld3dxbF9maWx0ZXIiOiJjcmVkaXRfbm90ZS5zdGF0dXMgPSBcIkZpbmFsaXNlZFwiIGFuZCAoIHByb2R1Y3QubmFtZSA9IOKAnERlcG9zaXQvU3RhdGllZ2VsZCBGdXN0ICgwJSnigJ0gb3IgcHJvZHVjdC5uYW1lID0g4oCcRGVwb3NpdC9TdGF0aWVnZWxkIEtlZ3MgVW5pdGVkIEZ1c3TigJ0gb3IgcHJvZHVjdC5uYW1lID0g4oCcRGVwb3NpdC9TdGF0aWVnZWxkIEtIIEZ1c3TigJ0gKSBhbmQgY3JlZGl0X25vdGUuY3JlYXRlZF9vbiA+PSBcIjAxLTEyLTIwMjRcIiJ9
— END BREWW RDE SHARE CODE —

Ahh, I think you may have smart quotes in there?

See:
Replace Smart Quotes Online

I have no idea what you are talking about. @ben-collard could you provide me with a solution.

Hi Gijs, Thanks for your reply. I would be very happy to test this BrewwQL in your account for you. Would it be okay if you raised a support ticket and granted the team access to your account, please? I will then be able to confirm what is needed here. Cheers!

The forum is mutilating postings… unless we remember to use the preformatted text widget. D’oh.

So:
( product.name = "Deposit/Statiegeld Fust (0%)" or product.name = "Deposit/Statiegeld Kegs United Fust" or product.name = "Deposit/Statiegeld KH Fust" )

The whole thing:

--- BEGIN BREWW RDE SHARE CODE ---
eyJiYXNlX2RhdGFfY29kZSI6ImNyZWRpdF9ub3Rlc19saW5lcyIsImZpZWxkc190b192aWV3IjoiY3JlZGl0X25vdGUubnVtYmVyLCBjcmVkaXRfbm90ZS5jdXN0b21lci5uYW1lLCBjcmVkaXRfbm90ZS5jdXN0b21lci50eXBlLnR5cGUsIHByb2R1Y3QubmFtZSwgcXVhbnRpdHksIHRvdGFsX25ldHRfYW1vdW50LCBjcmVkaXRfbm90ZS5jcmVhdGVkX29uIiwiYnJld3dxbF9maWx0ZXIiOiJjcmVkaXRfbm90ZS5zdGF0dXMgPSBcIkZpbmFsaXNlZFwiIGFuZCAoIHByb2R1Y3QubmFtZSA9IFwiRGVwb3NpdC9TdGF0aWVnZWxkIEZ1c3QgKDAlKVwiIG9yIHByb2R1Y3QubmFtZSA9IFwiRGVwb3NpdC9TdGF0aWVnZWxkIEtlZ3MgVW5pdGVkIEZ1c3RcIiBvciBwcm9kdWN0Lm5hbWUgPSBcIkRlcG9zaXQvU3RhdGllZ2VsZCBLSCBGdXN0XCIgKSBhbmQgY3JlZGl0X25vdGUuY3JlYXRlZF9vbiA+PSBcIjAxLTEyLTIwMjRcIiJ9
--- END BREWW RDE SHARE CODE ---

Ok. this works - no idea what the difference is between the previous

There’s a difference between
“Some Text Here”
and
"Some Text Here"

The first one has curly quotes (smart quotes), the second has straight quotes.

We want straight quotes. That’s one thing.

The main issue is (I guess) how BrewwQL processes all these ands and ors

It looks like
A or B or C and D

gets processed right to left. i.e. the C and D gets checked first. So it’s as if it was bracketed thus:
A or (B or (C and D))

In your example this means
product.name = "Deposit/Statiegeld KH Fust" and credit_note.created_on >= "01-12-2024" is evaluated first

But the date restriction isn’t then applied to the other two products.

However you go about it, you need something that says

The_Products_I_Want and The_Date_I_Want

So you have to explicitly bracket it the way you want:

(A or B or C) and D

Which convinces BrewwQL to evaluate A or B or C before having a look at the date.

Or, you use the in construction

product.name in ("NameA", "NameB", "NameC")

in that case, the problem just goes away.

See:
Introduction to BrewwQL - Breww docs