
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if Variable = x then y
Hi,
I need to create a new variable within my Data Manager using an IF Statement but unsure how to go about writing it.
I need it to say:
if(Purchase_order = 'RT' and Dist_type<> '', Dist_type, Purchase_order )
Any idea on the correct Qlik syntax for this please as it the calculated field doesn't appear to like 'and'?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems odd - I don't use Data Manager much so I gave it a go and you're right it doesn't accept AND although the documentation suggest that If is a valid data manager expression function that should behave like any other If() in the load script or a chart ...
However you can nest the If like this:
If( Purchase_order = 'RT' , If( Dist_type<>'' , Dist_type , Purchase_order), Purchase_order)
or
If( Puchase_order&'|'&Dist_type <> 'RT|' , Dist_type , Purchase_order)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A third work-around is to sum the boolean values of the comparisons as a true value is -1 and a false value is 0:
If( ((Purchase_order='RT') + (Dist_type<>''))=-2 , Dist_type, Purchase_order )
doesn't work however since the expression parser in the Data Manager is rather simplistic - so you have to use paranthesis around a lot of sub-expressions and even negative numbers - this works however:
If( ((Purchase_order='RT') + (Dist_type<>''))=(-2 ), Dist_type, Purchase_order )
