Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

Calculate Median from grouped data

Dear all,

I would like to calculate the median value  for each prescription ID as well as for each patient ID regarding product sales (see attached data example). 

I can calculate the average value for each patient by using "Sum([Sales per prescripton line])/Count(distinct(PAT_ID))".

I can calculate the median value of the prescription line but how do I get the median value for prescription ID and patient ID?

Thanks for your help.

Jörg

4 Replies
MVP & Luminary
MVP & Luminary

Re: Calculate Median from grouped data

Perhaps simply median([Sales per prescripton line])


talk is cheap, supply exceeds demand
Not applicable

Re: Calculate Median from grouped data

Thank you for your answer. I have already done that and got the median for prescription line but how do I obtain the median for prescription  and patient?

Jörg

MVP & Luminary
MVP & Luminary

Re: Calculate Median from grouped data

I don't understand what you want. Perhaps one of these three is what you're looking for:

  • median(aggr(sum([Sales per prescripton line]),[Patient ID]))
  • median(aggr(sum([Sales per prescripton line]),[Unique Prescription ID]))
  • median(aggr(sum([Sales per prescripton line]),[Patient ID],[Unique Prescription ID]))

talk is cheap, supply exceeds demand
Not applicable

Re: Calculate Median from grouped data

Hi Gysbert,

Sorry for not explaining it properly but you actually gave me the looked for answer.

Well done, thank you

Jörg