cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JeanMartinL
Advocate II
Advocate II

Variable format measure in a chart

Hello,

I already found a bunch of posts saying that what I'm trying to do is impossible but they are all a few years old so hopefully there is something new now to get around this issue.

 

Let's create the world's simplest table:

JeanMartinL_0-1652447981022.png

 

 

Let's say I want a single measure that depending on the category selected can return data in different formats, in my example Category 1 is a standard number, category 2 is a percentage.

I'll first create 2 intermediate measures for the individual values:

 

JeanMartinL_1-1652448049713.png

JeanMartinL_2-1652448071719.png

 

And then the global measure that switch between the 2.

JeanMartinL_3-1652448106577.png

This doesn't work, even though [PercentageData] is formatted as a Percentage, when used in [Data] it uses [Data]'s formatting option instead and returns the value as a number (expected behavior)

JeanMartinL_4-1652448287991.png

 

My solution to this was to use FORMAT in the [Data] measure:

JeanMartinL_5-1652448341003.png

This actually works fine for a Card or a Table, but doesn't work at all in any kind of chart:

JeanMartinL_6-1652448404084.png

 

My understanding of the issue is that FORMAT always return a text value, a datatype incompatible with the charts.

I tried a bunch of other things, like wrapping the expression in a VALUE or CONVERT but couldn't find a solution.

 

Is there any workaround that would enable me to show different formats from a single measure in a chart?

 

Thanks!

 

Caveat: I am using Power BI for Report Server January 2022, I'm not sure if the cloud version has the same behavior.

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@JeanMartinL,

 

Calculation groups allow you to customize formatting without converting numbers to text (as the FORMAT function does). Here are some links to get you started. You'll need Tabular Editor (free utility) to create calculation groups.

 

https://www.sqlbi.com/articles/introducing-calculation-groups/ 

https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
JeanMartinL
Advocate II
Advocate II

Ah very interesting, I learned about calculation groups a few weeks ago and I was looking for an opportunity to test them out, so this is perfect!

 

Thanks!

Excellent! Calculation groups are extremely useful, and can drastically reduce the number of measures in a data model, in addition to providing formatting flexibility.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




DataInsights
Super User
Super User

@JeanMartinL,

 

Calculation groups allow you to customize formatting without converting numbers to text (as the FORMAT function does). Here are some links to get you started. You'll need Tabular Editor (free utility) to create calculation groups.

 

https://www.sqlbi.com/articles/introducing-calculation-groups/ 

https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors