Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi everyone,
I am working on a report to show census and occupancy of our hospital where census is the count of patients, and occupancy is census/hospital beds. Therefore, census should be formatted as a number (with no decimal places) and occupancy should be a percentage.
There are several visuals where I want to switch between these metrics. For example, to show trends in census and occupancy over the past year, I built a line graph that allows me to switch the value of the graph by clicking a button. I used these instructions: https://powerbi.tips/2019/08/dynamic-visuals-using-buttons/
and the meausre is:
Metric =
SWITCH(
SELECTEDVALUE(Metric[Metric Number]),
1,[Occupancy],
2,[Census],
[Occupancy]
)
My problem is now that as I switch between occupancy and census, I cannot get the number formatting of that measure to change as well. Is there a way for me to format my metric to show % when I click the "Occupancy" button and a number when I click the "Census" button?
Any help would be appreciated! I cannot attach a real pbix file because of confidential patient information, unfortunately.
Solved! Go to Solution.
Hello @738o51,
Please try the following DAX:
Metric =
SWITCH(
SELECTEDVALUE(Metric[Metric Number]),
1,FORMAT([Occupancy],"Percent"),
2,[Census],
FORMAT([Occupancy],"Percent")
)
Let me know if this doesn't help.
Hello @738o51,
Please try the following DAX:
Metric =
SWITCH(
SELECTEDVALUE(Metric[Metric Number]),
1,FORMAT([Occupancy],"Percent"),
2,[Census],
FORMAT([Occupancy],"Percent")
)
Let me know if this doesn't help.
Thanks!
I used your Dax but made used "#%" rather than "Percent" to get rid of the decimal places.
I appreciate your help!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |