Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

kmstephenson
New Contributor III

calculating median with denominator restriction?

Hi All,

I would like to calculate the event length of stay for patients with an event (AnyEvent indicator set to 1) within a certain number of days of discharge from a hospital.  I calculated the average event length of stay for patients with an event by discharge location the following way:

Dimension: DischargeLocation

Expression: SUM({<DayNum={"<=$(vDaysOfInterest)"}>}AnyEvent)/COUNT({<AnyEvent*={1}>}DISTINCT EventKey)

I would also like to calculate median event length of stay *for patients with an event* by discharge location. How can I update the code below to aggregate by only patients with an event (i.e. denominator restriction {<AnyEvent*={1}>} )?

MEDIAN(AGGR(SUM({<DayNum={"<=$(vDaysOfInterest)"}>}AnyEvent),EventKey,DischargeLocation))

Thanks!!

1 Solution

Accepted Solutions

Re: calculating median with denominator restriction?

May be this:

Median(Aggr(Sum({<DayNum={"<=$(vDaysOfInterest)"}, AnyEvent*={1}>}AnyEvent),EventKey,DischargeLocation))

or

Median({<AnyEvent*={1}>} Aggr(Sum({<DayNum={"<=$(vDaysOfInterest)"}, AnyEvent*={1}>}AnyEvent),EventKey,DischargeLocation))

1 Reply

Re: calculating median with denominator restriction?

May be this:

Median(Aggr(Sum({<DayNum={"<=$(vDaysOfInterest)"}, AnyEvent*={1}>}AnyEvent),EventKey,DischargeLocation))

or

Median({<AnyEvent*={1}>} Aggr(Sum({<DayNum={"<=$(vDaysOfInterest)"}, AnyEvent*={1}>}AnyEvent),EventKey,DischargeLocation))

Community Browser