5 Replies Latest reply: Nov 25, 2014 10:08 PM by Renata Stepic

# Median value not showing in Straight Table

Hi,

I have a straight table with 2 values and I can't seem to get the Median to show for the NonAdmitted column. The if for the Admitted works but when I apply the same calculation for the NonAdmitted column, no data comes up. Is this because the IF statement can't handle more complicated calculations?

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),

))

• ###### Re: Median value not showing in Straight Table

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.

HIC

• ###### Re: Median value not showing in Straight Table

Thanks Hendric. When I put this expression into a normal text object it works so that is what I think it could have something to do with the Straight table where I need to include the and KPINEAT = 'NonAdmitted'. Can you advise what the expression should be as mentioned above?

• ###### Re: Median value not showing in Straight Table

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.

HIC

• ###### Re: Median value not showing in Straight Table

Hi Henric,

Renata's problem was that Qlikview wasn't evaluating the Fractile Funtion in that IF condition.

Once we changed to:

\$(=Fractile(aggr(\$(mEDNANeatDuratioinFirstSeentoDeparture_SelYr) ,[ED Episode No] ),0.5)),

if(KPINEAT = 'NonAdmitted' and LEFT(svNEATMeasure,1)=2, \$(mEDNANeatDuratioinFirstSeentoDeparture_SelYr),

))

it started working...

Thanks

• ###### Re: Median value not showing in Straight Table

Hi Daniel,

I just found that when I make other selections in the document, the values disappear in the table. Again this has something to do with the IF STatement.