Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
i have a problem when i try to create a new calculated field by using a Nested IF.
For example I have a Field Age and I want create a new Field (Color) with 'A' if Age > 10 and < 20, 'B' if Age >=20 and < 40 and so on...
I try to create this function but Qlik show me this error: missing right parenthesis:
if ( Age > 10 and Age < 20,A, |
7 | if ( Age >= 20 and Age < 40,B,)) |
Thanks,
Livio
If([City Code] > 100 and [City Code]<20, 'A',
If([City Code] >= 20 and [City Code] < 40, 'B'))
True, Qlik consider as 2 fields which called appending. So, you could try [City Code] instead City Code
If([City Code]> 100 and [City Code] <20, 'A', If([City Code] >= 20 and [City Code] < 40, 'B'))
If your field is called City Code, you have to use [City Code].
You should also name your column:
if(Stuff) as CityCodeColor
Hi,
I solve the problem by using the Data Loader but I don't undertand why it's no function using "Add Calculated Field" in Data Model
If..Else.. Available in Script and UI too. Where it not working for you? Can you show image at least?
Hi,
If i use the DATA MANAGER the result is:
By using Data Loader the script is ok and i'm able to create the calculated filed that you can see in the picture up.
Seems, Data manager also working. Where you facing the wrong values?
In the Data Manager like you can see in the picture
You may miss understanding the IF condition
If([City Code]> 10 and [City Code] <20, 'A', If([City Code] >= 20 and [City Code] < 40, 'B', 'C'))
Explanation - If [City Code] arbitrary between 10 and 20 then it returns only A and [City Code] arbitrary between 20 and 40 then it returns only B. That means, If [City Code] < 10 and [City Code] >40 it returns C only. The same way your functionality works
I'm sorry but if i use this script:
If([City Code]> 10 and [City Code] <20, 'A', If([City Code] >= 20 and [City Code] < 40, 'B', 'C'))
the result is ever wrong It's ok only if i use the data loader editor