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.
I created two measures
HE = SUM('Table'[Extra Hours] )
% HE = DIVIDE( [HE]; [Total Hours]; BLANK() )
Where HE is the sum of "Extra Hours" and %HE is Extra Hours / Total Hours
For the second one, I changed the format to % (if I put it on a visual, it works perfectly)
Than, I wanted to put both measures in the same visual and switch from one the another with a botton, putting this third measure in the visual:
HE or %HE = SWITCH(TRUE();
[Case] = 1; [HE];
[Case] = 2; [% HE];
BLANK()
)
This new measure works perfectly to switch from HE to %HE.
The problem is: when I switch to %HE, it looses the %format I gave to the original measure.... If I change the "HE or %HE" measure's format to %, both measures HE, %HE will be in %... which is also wrong.
Anyone help me?
PS: "Case" is a measure: the max of the first column of a table 2x2 like below (thus, returning 1 or 2)
1 HE
2 %_HE
Which I use as data segmentation (the button to change from a measure to another in a visual). If I select HE, it filters the table, then the Case measure returns 1. If I select %_HE, Case returns 2.
@Anonymous,
Please change your DAX to the following:
HE or %HE = SWITCH(TRUE();[Case]=1;[HE];[Case]=2;FORMAT([% HE];"percent");BLANK())
Regards,
Lydia
Hello Lydia,
Thank you for your answer. However, I still have an issue.
I wrote as you told me to, although it works perfectly in a table, when I select a visual, it returns blank! 😞
HE or %HE = SWITCH(TRUE();
[Case] = 1; [HE];
[Case] = 2; FORMAT([% HE]; "percent");
BLANK())
Why? 😞
it turns to blank beacause FORMAT converts numeric value to text
you may consider having 2 measures - one with FORMAT for tables and second without it for visuals
not sure if there is a cleaner solution to it though
@Anonymous,
Could you please share sample data of your tables here so that I can reproduce the whole report?
Regards,
Lydia
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 |
---|---|
111 | |
94 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |