Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm wondering how Qlikview handles Nested If Statments. For example, is there a difference between the code below
Example 1:
if( x > y, 'Yes',
if( J = U, 'Missing',
if(R < H, 'Hung Up', 'Successful'))) as [Call Outcome]
Example 2:
if(x>y, 'Yes') as [Call Outcome]
if(J=U, 'Missing') as [Call Outcome]
if( R < H, 'Hung Up', 'Successful') as [Call Outcome]
your Example2 won't run
you can only define one fieldname
otherwise you get an error message
you Need to use a nested if like example 1
Hi Seth,
I don't think code from Example 2 would work in your load script as I would expect QV to return an error - something like "columns in your tables must have unique names" --> let's not forget that QV builds the association between the tables based on field name (and it is case sensitive), so it will not allow you to create 3 [Call Outcome] fields.
Example 1 would work - of course considering that that's the logic you need in your script.
Hope that helps, good luck!
I think you get a syntax errore for the second one
Ok, so example 2 won't work. Disregarding how qlikview would handle this, is the logic at least the same. In other words, in qlikview you must nest the if statements, but really all the logic is, is a bunch of if statements together with no difference in priority. Does that make sense?
No difference in priority? Do you mean you would like all if statements to produce a value?
If so you might want to take a look at the crosstable load, see help and/or
A example for your situation would be something like this
Database:
Load ID,x,y,J,U,R,H
From...
CrossTable(Metric,Data,1) load
ID,
if(x>y, 'Yes') as [Call Outcome],
if(J=U, 'Missing') as [Call Outcome],
if( R < H, 'Hung Up', 'Successful') as [Call Outcome]
resident Database;
There won't be any difference in nested if else, you can use the same logic as you would do in any programming language. Your second one will give error for field names as the Qv works on field name.