Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bpb
Contributor II
Contributor II

Error: Missing right parenthesis for calculated column using if / and

I am trying to build a simple calculated column as shown below using an If statement with an and operator. How can I rewrite my expression to resolve the "Missing right parenthesis" error

IF(Type='A' and Unit = 'B', 1, 0)

bpb_0-1615840336660.png

 

Labels (4)
1 Solution

Accepted Solutions
Or
MVP
MVP

Gotcha - I've never actually used this, didn't even realize it was there! Learn something new every day...

It looks to me like this particular editor doesn't have an 'and' option, which is a tad weird because it's legal Qlik syntax when used in the script editor. Assuming you'd like to remain in Data Manager mode rather than using Script Editor, you could work around it by using a nested if statement - If(Type = 'A', if(Unit = 'B',1,0),0) though I appreciate that is a tad clunky. Perhaps someone else with more knowledge about Data Manager can help you do it more cleanly, though...

View solution in original post

3 Replies
Or
MVP
MVP

Where exactly are you entering this formula? It appears to be correct in Qlik Sense as written (assuming Type and Unit are fields in your app), and the 'and' should be picked up as a keyword and highlighted in blue... but this doesn't look like the standard Qlik Sense formula editor?

bpb
Contributor II
Contributor II
Author

Hi, I am entering my formula in the data manager tab. I am new to Qlik -- Do you know if this is not the appropriate place to be adding calculated fields? Oddly, when I reduce my calculated field expression to just an and operator, I get another error: "Unexpected token: and".

bpb_0-1615841774674.png

 

Or
MVP
MVP

Gotcha - I've never actually used this, didn't even realize it was there! Learn something new every day...

It looks to me like this particular editor doesn't have an 'and' option, which is a tad weird because it's legal Qlik syntax when used in the script editor. Assuming you'd like to remain in Data Manager mode rather than using Script Editor, you could work around it by using a nested if statement - If(Type = 'A', if(Unit = 'B',1,0),0) though I appreciate that is a tad clunky. Perhaps someone else with more knowledge about Data Manager can help you do it more cleanly, though...