Forum Discussion
Dynamic x axis with different formatting in a bar chart
Hi,
I'm trying to have a bar chart with a dynamic x-axis based on a slicer selection. The users should be able to select % or # in a slicer and the result should either be shown in percentage or whole number. The issue that I'm facing is that I can't seem to be able to get the fomatting done correctly.
I've tried different expressions but they all seem to format the values as text. And it doesn't seem like I can have text as "Values" in a bar chart. It works fine in a table, but not in a bar chart.
[Package Conversion] and [Packages] seen below are two separate measures.
My expression is:
Packages Confirmed =
IF(
HASONEVALUE(MeasureSelection[Selection]),
SWITCH(
VALUES(MeasureSelection[Selection]),
"%",
FORMAT([Package Conversion],"Percent"),
"#",
FORMAT([Packages],"General number")
)
)
I've also tried with this expression as I saw in another post, but I didn't get it to work either.
Packages Confirmed =
SWITCH(
VALUES(MeasureSelection[Selection]),
"%",
FORMAT([Package Conversion],"0.00%;(0.00%);0"),
"#",
FORMAT([Packages],"0.00;(0.00);0")
)
Is this possible in Power BI? Or do I have to look into calculation groups in Tabular Editor?
Sincerely
Dash
Hi PBI-Dash
This can be done using tabular editor and calculation groups.
Check the blog post below about how you can achieve this:
https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/
1 Reply
- MFelix
Super User
Hi PBI-Dash
This can be done using tabular editor and calculation groups.
Check the blog post below about how you can achieve this:
https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/