Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Act sooner with Multivariate Time Series in Qlik Predict™: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average Calculation problem


Hi all,

I have a data as per the table below. I am trying to calculate an average and have used sum(cost)/sum(activity). This works fine for the total ie 1000/500 = 2 and for the ward 600/500=1.2.

However, theatre is returning 400/2 = 200 as only 2 patients used the theatre. I would like an average that returns 400/500 = 0.8 as an average cost for all the patients.

Any help gratefully received.

thanks

ian

Cost type

CosttypeTotal CostTotal Activity
Total1000500
Ward600500
Theatre4002
1 Solution

Accepted Solutions
Not applicable
Author

Hi Ian

Try

sum(cost)/sum(Total activity).


best regards

View solution in original post

3 Replies
Not applicable
Author

Try this,

Sum(if(costtype='Theatre',Total Cost) / Sum(if(costtype='Ward',Total Activity)

MK_QSL
MVP
MVP

Try

sum(cost)/sum(TOTAL activity)

or

sum(cost)/sum({1}activity)

or

sum(cost)/COUNT(DISTINCT activity)

or

sum(cost)/sum(DISTINCT activity)


Not applicable
Author

Hi Ian

Try

sum(cost)/sum(Total activity).


best regards