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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Les111
Resolver I
Resolver I

Format values when using dynamic metrics and dimensions

I have a chart where the user can select both metric and dimension in slicers, e.g there are metrics for appointments and DNA %. These metrics are displayed dynamically based on a DAX measure which selects whichever one is selected in the slicer. 

 

The dimension, (e.g. age group, ethnicity etc) is selected in another slicer which is populated by a calculation group, with an expression like this for each dimension:

CALCULATE( SELECTEDMEASURE(), USERELATIONSHIP(DimensionIndex[UniqueID], DIM_Ethnicity[UniqueID]) )

The chart looks like this and works beautifully where all the values are whole numbers, but I have a metric that is a percentage which needs to be formatted as a %:

Les111_0-1644396291869.png


I have tried formatting the value in the source measure and in my DAX measure that selects the metric, but this breaks the chart, and instead of showing the selected dimension in the legend it shows all the values for every dimension:

 
Les111_1-1644398312008.png

 

Any ideas as to how to format individual metrics in this situation?

Thanks

Leslie

 

1 ACCEPTED SOLUTION
Les111
Resolver I
Resolver I

Well, as often happens, I worked this out myself soon after posting this, and with a bit of help from this video: Dynamic NUMBER FORMATTING using CALCULATION GROUPS in Power BI - YouTube

 

To fix this I added a format column to my metrics table (values are 0 for number metrics and #0.0% for percentages). Then I created a new calculation group with just one item called format, which has the expression SELECTEDMEASURE() and the format string expression is SELECTEDVALUE(Metrics[Format]). 

 

Finally I added a filter to the chart, which is the 'name' field from the calculation group and selected the column in it.

View solution in original post

1 REPLY 1
Les111
Resolver I
Resolver I

Well, as often happens, I worked this out myself soon after posting this, and with a bit of help from this video: Dynamic NUMBER FORMATTING using CALCULATION GROUPS in Power BI - YouTube

 

To fix this I added a format column to my metrics table (values are 0 for number metrics and #0.0% for percentages). Then I created a new calculation group with just one item called format, which has the expression SELECTEDMEASURE() and the format string expression is SELECTEDVALUE(Metrics[Format]). 

 

Finally I added a filter to the chart, which is the 'name' field from the calculation group and selected the column in it.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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