Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
On May 18th at 10AM EDT we will answer your QlikView questions live. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
kmstephenson
Creator
Creator

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
sunny_talwar

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

View solution in original post

1 Reply
sunny_talwar

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

View solution in original post