The If() function can handle much more complex (but correctly written) calculations...
Your expression contains many things that could be problems:
- The first condition is KPINEAT = 'NonAdmitted' and LEFT(svNEATMeasure,1)=1 which is an expression that lacks aggregation functions. Hence, it will most likely evaluate to NULL. The same is true for the condition of the 2nd If(). Read Use Aggregation Functions!.
- The second parameter of the first If() contains a Fractile( aggr( $(mEDNANeatDuratioinFirstSeentoDeparture_SelYr), ... which may or may not work, depending on whether your variable contains an aggregation function or not. It should contain one, otherwise this will evaluate to NULL,
- The second parameter of the second If() is empty. It shouldn't be. Enter the Null() function or a text string 'Error' enclosed in single quotes.
In a text box, the above problems would become even worse... For instance, if you have records where KPINEAT is 'Admitted', then the condition KPINEAT = 'NonAdmitted' will always evaluate to FALSE, since it is evaluated to Only(KPINEAT) = 'NonAdmitted', i.e. NULL = 'NonAdmitted'.
What you probably should do, is to move this condition into the aggregation function that is hidden in mEDNANeatDuratioinFirstSeentoDeparture_SelYr, but since I don't know what you have there, I cannot say for sure.
Renata's problem was that Qlikview wasn't evaluating the Fractile Funtion in that IF condition.
Once we changed to:
if(KPINEAT = 'NonAdmitted' and LEFT(svNEATMeasure,1)=1,
$(=Fractile(aggr($(mEDNANeatDuratioinFirstSeentoDeparture_SelYr) ,[ED Episode No] ),0.5)),
if(KPINEAT = 'NonAdmitted' and LEFT(svNEATMeasure,1)=2, $(mEDNANeatDuratioinFirstSeentoDeparture_SelYr),
it started working...