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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cheid_4838
Helper IV
Helper IV

Changing format when using measures in a slicer

I have a visual where I have created a slicer to switch between different measures.  Some of the measures our percentages, dollars, and just decimal.  I tried changing the format, but it won't change.  How do I go about changing the format when using measures in a slicer so the format is reflected in the visual?  Thanks.

 

 

 

cheid_4838_1-1733494801539.png

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

hi @cheid_4838 

 

In the slicer tabe, add a column that indicates the format string. For example

Measure Name Format String
Dollar Value $#,#
Percentage 0.00%
Volume #,#

 

 

Now, select the measure that switches between different measures. Go to format under the measure contextual tab. Click Dynamic from the dropdown.

danextian_0-1733496155413.png

 

Enter SELECTEDVALUE('slicer'[format string]) in the formula bar.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

hi @cheid_4838 

 

In the slicer tabe, add a column that indicates the format string. For example

Measure Name Format String
Dollar Value $#,#
Percentage 0.00%
Volume #,#

 

 

Now, select the measure that switches between different measures. Go to format under the measure contextual tab. Click Dynamic from the dropdown.

danextian_0-1733496155413.png

 

Enter SELECTEDVALUE('slicer'[format string]) in the formula bar.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ritaf1983
Super User
Super User

Hi @cheid_4838 
To dynamically change the format of your values based on the measure selected in your slicer, you can use a combination of SWITCH and a calculated DAX measure. While Power BI does not natively support dynamic format strings for measures in field parameters, you can simulate this by creating a measure for formatting your values.

Example DAX Measure
DAX
Copy code
FormattedMeasure =
VAR SelectedMeasure = SELECTEDVALUE('MeasureSelector'[MeasureName])
RETURN
SWITCH(
TRUE(),
SelectedMeasure = "Percentage Measure", FORMAT([YourPercentageMeasure], "0.00%"),
SelectedMeasure = "Currency Measure", FORMAT([YourCurrencyMeasure], "$#,##0.00"),
SelectedMeasure = "Decimal Measure", FORMAT([YourDecimalMeasure], "0.00"),
BLANK() // Default value if no measure is selected
)

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

I created this measure and entered the FORMAT in the return statement, but I am getting an error message shown below.  I even tried it with additional parenthesis and still didn't work.  Is FORMAT in the wrong location within the measure?

cheid_4838_0-1733497233834.png

 

Allocated Tractor Cost =
--Calculate the Total Count for each slicer--
VAR TotalCountRouteID = CALCULATE(SUM('STOPS'[COUNT]), ALL('STOPS'[RouteID]))
VAR TotalCountStopID = CALCULATE(SUM('STOPS'[COUNT]), ALL('STOPS'[StopID]))
VAR TotalCountStopDescription = CALCULATE(SUM('STOPS'[COUNT]), ALL('STOPS'[StopName] ))

--Calculate the Line Distribution Count for each slicer--
VAR LineDistCountRouteID = DIVIDE([Line Count], TotalCountRouteID)
VAR LineDistCountStopID = DIVIDE([Line Count], TotalCountStopID)
VAR LineDistCountStopDescription = DIVIDE([Line Count], TotalCountStopDescription)

--Apply the percentage to the cost and operational numbers--
VAR AllocatedCostRouteID = CALCULATE(LineDistCountRouteID * sum(Invoice[Tractor Cost]))
VAR AllocatedCostStopID = CALCULATE(LineDistCountStopID * sum(Invoice[Tractor Cost]))
VAR AllocatedCostStopDescription = CALCULATE(LineDistCountStopDescription * sum(Invoice[Tractor Cost]))

--Create a measure to dynamically switch between the slicers--

RETURN
SWITCH(
TRUE(),
ISFILTERED('STOPS'[RouteID]), AllocatedCostRouteID,Format(AllocatedCostRouteID,"$#,##0.00"),
ISFILTERED('STOPS'[StopID]), AllocatedCostStopID, Format(AllocatedCostStopID,"$#,##0.00"),
ISFILTERED('STOPS'[StopName]), AllocatedCostStopDescription,Format(AllocatedCostStopDescription,"$#,##0.00"),
SUM(Invoice[Tractor Cost])  // Default case if no slicer is selected
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.