Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.