Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I have a stacked column report where i would like to chamge data format based on slicer selection. I put the below code under data labels-values, custom labels- field. Code works for the most part except for when trade rate is selected in the slicer. Below you will find the screen shot of results when trade rate is selected. How can i show actual percentage rather than 0.0%. Thanks
Output Sales Format =
VAR Sales = CALCULATE(Output[Output Selected Calculation])
VAR SlicerSelection = SELECTEDVALUE('Output Slicer Table'[P&L])
VAR FormatString = IF(SlicerSelection = "ASP" || SlicerSelection = "ansp" || SlicerSelection = "cogs", "0.00", IF(SlicerSelection = "Trade Rate", "0.0%", IF(Sales > 1000000, "0.0M", "0.0K")))
VAR RoundedSales = IF(SlicerSelection = "ASP" || SlicerSelection = "ansp" || SlicerSelection = "cogs", ROUND(Sales, 2), IF(Sales > 1000000, ROUND(Sales/1000000, 1), ROUND(Sales/1000, 1)))
RETURN
FORMAT(RoundedSales, FormatString)
Solved! Go to Solution.
i figured out. i modified the code little bit.
Output Sales Format =
VAR Sales = CALCULATE(Output[Output Selected Calculation])
VAR SlicerSelection = SELECTEDVALUE('Output Slicer Table'[P&L])
VAR FormatString = IF(SlicerSelection = "ASP" || SlicerSelection = "ansp" || SlicerSelection = "cogs", "0.000", IF(SlicerSelection = "Trade Rate",format(CALCULATE(Output[Output Selected Calculation]),"0.0%"), IF(Sales > 1000000, "0.0M", "0.0K")))
VAR RoundedSales = IF(SlicerSelection = "ASP" || SlicerSelection = "ansp" || SlicerSelection = "cogs", ROUND(Sales, 3), IF(Sales > 1000000, ROUND(Sales/1000000, 1), ROUND(Sales/1000, 1)))
RETURN
FORMAT(RoundedSales, FormatString)
@dokat you can take advantage of the new dynamic format option available in Power BI, check out the video here: From Thousands to Billions: The Power of Dynamic Formatting in Power BI - April 2023 Power BI Update...
👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
i figured out. i modified the code little bit.
Output Sales Format =
VAR Sales = CALCULATE(Output[Output Selected Calculation])
VAR SlicerSelection = SELECTEDVALUE('Output Slicer Table'[P&L])
VAR FormatString = IF(SlicerSelection = "ASP" || SlicerSelection = "ansp" || SlicerSelection = "cogs", "0.000", IF(SlicerSelection = "Trade Rate",format(CALCULATE(Output[Output Selected Calculation]),"0.0%"), IF(Sales > 1000000, "0.0M", "0.0K")))
VAR RoundedSales = IF(SlicerSelection = "ASP" || SlicerSelection = "ansp" || SlicerSelection = "cogs", ROUND(Sales, 3), IF(Sales > 1000000, ROUND(Sales/1000000, 1), ROUND(Sales/1000, 1)))
RETURN
FORMAT(RoundedSales, FormatString)
@parry2k Thanks. In theory the code i have works in similar way in the vide you shared, The issue i am coming accross is when trade rate slicer is selected it returns "0.0%" as text rather than 20.5% or 38.2%. It iis not returning number. Strangely all others formula works fine.
User | Count |
---|---|
94 | |
79 | |
74 | |
64 | |
60 |
User | Count |
---|---|
106 | |
97 | |
76 | |
63 | |
61 |