The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Please help. I am almost certain that mine is a simple problem with a simple solution but I have spent quite a number of days on it without a breakthrough. Below is a sample of a large spreadsheet of patient data that I'm using to measure and visualize hospital performance on some metrics in Power BI Desktop. One of the metrics is the percentage of patients who have a pressure ulcer (an injury to the skin caused by prolonged pressure on the skin when patients are in bed for long periods).
Patient | Hospital | Date | Pressure Ulcer Present |
101100 | H01 | 28/07/2022 | No |
101101 | H01 | 28/07/2022 | Yes |
101102 | H01 | 28/07/2022 | Yes |
101103 | H01 | 28/07/2022 | Yes |
101104 | H02 | 28/07/2022 | No |
101105 | H02 | 28/07/2022 | No |
101106 | H02 | 28/07/2022 | Yes |
101107 | H02 | 28/07/2022 | No |
101108 | H03 | 28/07/2022 | Yes |
101109 | H03 | 28/07/2022 | No |
101110 | H03 | 28/07/2022 | No |
101111 | H03 | 28/07/2022 | Yes |
101112 | H04 | 28/07/2022 | No |
101113 | H04 | 28/07/2022 | No |
101114 | H04 | 28/07/2022 | No |
101115 | H04 | 28/07/2022 | Yes |
101116 | H05 | 28/07/2022 | Yes |
101117 | H05 | 28/07/2022 | Yes |
101118 | H05 | 28/07/2022 | No |
101119 | H05 | 28/07/2022 | No |
101120 | H05 | 28/07/2022 | No |
So for this example, I am using a DAX measure to calculate the Pressure Ulcer metric for each Hospital as a percentage of patients with a pressure ulcer as follows:
Hospital | Pressure Ulcer Metric |
H01 | 75% |
H02 | 25% |
H03 | 50% |
H04 | 25% |
H05 | 40% |
Average Pressure Ulcer Metric | 43% |
Median Pressure Ulcer Metric | 40% |
Minimum Pressure Ulcer Metric | 25% |
Maximum Pressure Ulcer Metric | 75% |
I have struggled to get this to work and I haven't seen anything similar to this on the forum. So I would appreciate some help. Thanks.
Solved! Go to Solution.
Hi @RonD ,
I think you can try measures as below.
Average Pressure Ulcer Metric =
AVERAGEX(VALUES(Patients[Hospital]),[Pressure Ulcer Metric])
Median Pressure Ulcer Metric =
MEDIANX ( VALUES ( Patients[Hospital] ), [Pressure Ulcer Metric] )
Maximum Pressure Ulcer Metric =
MAXX ( VALUES ( Patients[Hospital] ), [Pressure Ulcer Metric] )
Minimum Pressure Ulcer Metric =
MINX(VALUES(Patients[Hospital]),[Pressure Ulcer Metric])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@RonD , The above should give correct Avg -Pressure Ulcer Metric
try
AverageX(Values('Patients'[Patients]) , [Pressure Ulcer Metric])
MAxx(Values('Patients'[Patients]) , [Pressure Ulcer Metric])
Minx(Values('Patients'[Patients]) , [Pressure Ulcer Metric])
MedianX(Values('Patients'[Patients]) , [Pressure Ulcer Metric])
Thank you @amitchandak. I realise that I may not have properly explained what I am trying to achieve and so I have edited my post to make it clearer. Your suggestion just reproduces the individual Hospital Pressure Ulcer Metrics which I am able to calculate with the DAX code in my post and a slicer on the Hospital column. But after calculating the measure for each Hospital, I would like to calculate the Average, Median, Minimum, and Maximum across all the individual Hospital measures (in order to give hospital managers some idea of where they stand against other hospitals): this is what I am struggling to do.
Hi @RonD ,
I think you can try measures as below.
Average Pressure Ulcer Metric =
AVERAGEX(VALUES(Patients[Hospital]),[Pressure Ulcer Metric])
Median Pressure Ulcer Metric =
MEDIANX ( VALUES ( Patients[Hospital] ), [Pressure Ulcer Metric] )
Maximum Pressure Ulcer Metric =
MAXX ( VALUES ( Patients[Hospital] ), [Pressure Ulcer Metric] )
Minimum Pressure Ulcer Metric =
MINX(VALUES(Patients[Hospital]),[Pressure Ulcer Metric])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
That works! Thanks @Anonymous
User | Count |
---|---|
15 | |
13 | |
9 | |
6 | |
6 |
User | Count |
---|---|
28 | |
18 | |
13 | |
9 | |
5 |