Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
pal25
Contributor III
Contributor III

If & and condition isnt working in the calculated field

Hi all,

I am finding error in this below formula. It says "Missing right parenthesis"

IF ([Country] = 'India' AND  Age < 5,'Yes',IF ([Country] <>'India' AND Age < 10,'Yes','No'))

Can someone help to identify the error. I am new to this tool and willing to learn

 

 

Labels (5)
13 Replies
pal25
Contributor III
Contributor III
Author

I am writing this formula under data manager -> add field -> add calculated field ->Expression (window)

Hope this is the correct way or is there any other way

vinieme12
Champion III
Champion III

Yes, there is another way

Instead of Data Manager,   Go to Data Load Editor

Add your data and load it into the app

>> GO to Data Load Editor

>> You should see a script that loads all the fields from your data as below

 

Load
field1
,field2
,field3
FROM YOURDATASOURCE;

 

>> you can create a new field here

 

Load
field1
,field2
,field3
,IF ([Country] = 'India' AND  Age < 5,'Yes',IF ([Country] <>'India' AND Age < 10,'Yes','No')) as  MyNewField
FROM YOURDATASOURCE;

 

>> After adding the calculation condition for the new field

Reload the app again, you should see the field you added

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
pal25
Contributor III
Contributor III
Author

I followed the above process and getting error even in script editor when i try to load it. Probably the "AND " is causing some issue not sure how to write this formula in another way to make it work

vinieme12
Champion III
Champion III

Can you post a screenshot of the error message?

And a screenshot of the entire script as there is mostly likely a scripting error

To confirm AND / OR  both work in script editor

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.