The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all!
I have simple sales data that I am trying to show in a bar chart visual. I am trying to manipulate what kind of units does the visual use, depending on the applied filters. What should be my approach to achieve this?
Here is sample data I am working with:
ID | Color | Price |
1 | Red | 80000 |
2 | Red | 140000 |
3 | Red | 30000 |
4 | Red | 180000 |
5 | Red | 50000 |
6 | Red | 160000 |
7 | Blue | 768 |
I have created a simple measure: Sales = sum(Sheet1[Price])
For my use case, "0,64M" is not very descriptive, and I need to see it in thousands. I see two options to do this:
1) Changing the units in ''X-axis'' to thousands.
2) Changing the units in ''Data labels'' to thousands.
However, when I select the slicer to show only sum of items sold with ''Blue'', both options will still display the value in thousands:
This is also not very descriptive, in this case I would want to see ''None'' units applied.
Would there be any solution which lets me change the displayed units based on some conditions?
Thank you all in advance!
Solved! Go to Solution.
You could use dynamic format strings - https://www.sqlbi.com/articles/introducing-dynamic-format-strings-for-dax-measures/
You could use dynamic format strings - https://www.sqlbi.com/articles/introducing-dynamic-format-strings-for-dax-measures/
Hi @johnt75
This is a great feature I was not aware of! This will help me a lot in future, thanks for sharing it!
Although, I can't fully figure it out.
I have written a simple format measure: if (SELECTEDMEASURE() <= 10000, "#0", "#,##0,")
So, if the measure is less than 10000, none units are displayed and if it's higher than 10000 then thousands are displayed. Works wonderfully! However, I can't figure out how to add the ''K'' in this measure to indicate that those are thousands.
According to the custom format strings https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-custom-format-strings I should add a backslash or double quotation marks to display a character. However, editing the measure to
1) if (SELECTEDMEASURE() <= 10000, "#0", "#,##0,\K") breaks the measure and none units are displayed in both cases
2) if (SELECTEDMEASURE() <= 10000, "#0", "#,##0,"K"") breaks the measure and my visualizations can no longer be displayed
3) if (SELECTEDMEASURE() <= 10000, "#0", "#,##0, K") also breaks the measure although it seems to work in the link you provided.
Any suggestions with how to solve this?
Try
IF ( SELECTEDMEASURE() <= 10000, "#0", "#,0,.00 K" )
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |