Forum Discussion
Formatted Value - an apostrophe as a separator
Hello,
I would like to use a measure to make sure my numbers are displayed in the correct format with an apostrophe as a separator.
I created this measure which works great in KPI Card, but I cannot use it in bar chart.
Hi Emma_, the reason your measure doesn't work with bar chat is that its result is no longer a number, but a text, which is the result of the SUBSTITUTE() function. Card visual allows you to display both, bar chart accepts only numbers in "Y-axis" section.
What you want to achive is somehow related to this article - Use custom format strings in Power BI Desktop - Power BI | Microsoft Learn. However, I've tested it with apostrophe and it doesn't work.
Therefore, I see only one alternative: having a numeric unformatted KPI and its "text twin". Whenever you need to make a calculation use the unfromatted KPI, and then use "text twin" in display option like in the image below (I've added pbix as well).
Good luck with your project!Thanks a lot for your answer. My scenario is a little bit more complex because I use a lot of measure branching. So I first take base measure like a sum and then I pull into the measure to calculate YTD values. Afterwards I use switch to get accordingly YTD current year, YTD-1 etc. And this final measure is being wrapped in the format function and used in the visual. Do you know any other solution?
Try this ...
Create some test data
Create 2 measures (one with and and one without the apostrophe)
MyMeasure1 = SUM(Pets[Value])MyMeasure2 = SUBSTITUTE(FORMAT([MyMeasure1], "#,0"), ",", "'")Draw your a stacked bar char with Y-axis = Pets and X-axis = [MyMeasure1]
Then in Format turn on Data Labels.
Scroll down and tun on Detail using [MyMeasure2]Please click thumbs up because I have tried to help.
Then click [accept solution] if it works. (you can see it does work in the above example)
Thank you !
Unfortunately, I don't see any alternatives to the one shared in this thread before...
5 Replies
- bhanu_gautamSuper User
Emma_ Create a measure for the numerical value that will be used in the bar chart.
MyMeasure = SUM(Table[Column])
Formatted Text Measure:
MyFormattedMeasure = SUBSTITUTE(FORMAT([MyMeasure], "#,0"), ",", "'")
In your bar chart, use MyMeasure for the actual values, and if you need to display the formatted values (e.g., in tooltips or labels), use MyFormattedMeasure
- Sergii24Super User
Hi Emma_, the reason your measure doesn't work with bar chat is that its result is no longer a number, but a text, which is the result of the SUBSTITUTE() function. Card visual allows you to display both, bar chart accepts only numbers in "Y-axis" section.
What you want to achive is somehow related to this article - Use custom format strings in Power BI Desktop - Power BI | Microsoft Learn. However, I've tested it with apostrophe and it doesn't work.
Therefore, I see only one alternative: having a numeric unformatted KPI and its "text twin". Whenever you need to make a calculation use the unfromatted KPI, and then use "text twin" in display option like in the image below (I've added pbix as well).
Good luck with your project! - Emma_Helper II
Thanks a lot for your answer. My scenario is a little bit more complex because I use a lot of measure branching. So I first take base measure like a sum and then I pull into the measure to calculate YTD values. Afterwards I use switch to get accordingly YTD current year, YTD-1 etc. And this final measure is being wrapped in the format function and used in the visual. Do you know any other solution?
- Sergii24Super User
Unfortunately, I don't see any alternatives to the one shared in this thread before...
- speedrampsSuper User
Try this ...
Create some test data
Create 2 measures (one with and and one without the apostrophe)
MyMeasure1 = SUM(Pets[Value])MyMeasure2 = SUBSTITUTE(FORMAT([MyMeasure1], "#,0"), ",", "'")Draw your a stacked bar char with Y-axis = Pets and X-axis = [MyMeasure1]
Then in Format turn on Data Labels.
Scroll down and tun on Detail using [MyMeasure2]Please click thumbs up because I have tried to help.
Then click [accept solution] if it works. (you can see it does work in the above example)
Thank you !