Forum Discussion
Buttons that change data labels
- 5 years ago
Anonymous If you want them to be able to choose, you'll need to get a little fancy with measures AND bookmark or parameter slicer. If you want to display both, you only need measures.
Create new measures:
Absolute Value = COUNT(Table[SalesDocuments])
Percent = DIVIDE([Absolute Value], CALCULATE([Absolute Value], ALL(Table[Division]))
Create a new table visual, with both measures in it and Division.
Now for the fancy part:
Option A: Slicer
Click 'Enter Data'
Paste this table:
Show Value As Absolute Percent Put Slicer[Show Value As] column in a slicer visual.
Create a new measure:
Value = SWITCH(SELECTEDVALUE(Slicer[Show Value As]), "Absolute", [Absolute Value], "Percent", FORMAT([Percent], "#.00%"), [Absolute Value])Put the [Value] measure in your table and test the slicer.
Option B: Bookmarks
Duplicate the table. Remove [Percentage] from one table and remove [Absolute Value] from the other table. Hide the Percentage table, create a new bookmark, name it 'Absolute Value'. Click the three dots and untick 'data' and 'current page'. Now unhide percentage table and hide absolute value table. Repeat bookmark creation process, but name it 'Percentage'.
Add a button for each bookmark.
Anonymous Excellent questions. I have added a file to my original post that hopefully makes it more clear. I also updated the DAX to use SELECTEDVALUE and to account for if there is no selection. I also added formatting to get the percent formatted properly.
Let me know if you have any other queries. Please @ mention me so I don't miss it. 🙂
- Anonymous5 years agoNot applicable
Hi AllisonKennedy thank you very much for the answers!
I understand now how you did it, however for whatever reason I wasn't able to achieve the same results. I created a dummy dataset to try it in those simplified conditions, but it didn't work as well. So I would very much appreciate if you could take a swift look and tell me where I've gone wrong... From my point of view I did it exactly as instructed...
Only things I changed were the names of the tables (but I adapted them in the formula), choose "SaTy" instead of Division but, like said, I adjusted the formula accordingly and I removed the Measures from the Value field in the visual to achieve the desired look. But also adding them back didn't change a thing an I realy can't tell why it doesn't work. I first thought its because the Measures aren't named exactly equal to the values in the slicer, but the formula for the Value-measure takes care of that so can't be that...
Can't attach samples so I'll just send screenshots:
- AllisonKennedy5 years agoCommunity Champion
Anonymous You made the same error I made in my original post - the measure says 'Percent' but the slicer says 'Percentage'. They must both match. Update your Value measure to say 'Percentage' and it should work.
- Anonymous5 years agoNot applicable
Hi AllisonKennedy that was exactly it! Thank you so much as it works now 🙂
One more question would be how to change the way its displayed in other visuals?
E.g. in the pie chart it doesn't make a difference if I use the "Value measurement" or not. I need the "SaTy Percent" measurement anyway cause the Value measurement seems not sufficient for PowerBI to build a pie chart in Percent (guess because PowerBI Can't calculate in percent?).
Unfortunately, then the "Percent" tags are not displayed as percent anymore, but as decimals:
What I should remark: I changed the data label to "Values", cause otherwise it also displays the percentage (not desired) when slicer is on "Absolute". WHen I change the data label to "Percentage of total for example, that issues isn't anymore, but then I got **bleep** 0% in the gapes of the chart:
Its all a big misery tho...