Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar

Perhaps simply median([Sales per prescripton line])


talk is cheap, supply exceeds demand
Not applicable
Author

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

Gysbert_Wassenaar

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
Author

Hi Gysbert,

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

Well done, thank you

Jörg