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
x-datita
Frequent Visitor

Apply the specific format by measure

Hello!

I have a problem with some visualizations, how can I make that when I select "sales" or "quantity" the format of the measurements is displayed correctly?

I created some daxes, but if I select "sales" in the slicer, the data figures should be displayed in currency format. And if I select "quantity" the format should be a whole number, but this doesn't work well.

xdatita_1-1692142229997.png

I share with you the .pbix 

https://drive.google.com/drive/folders/1HeccYaKR3eNvJpec9mEJMENbzVQ6MBPE?usp=sharing

I hope you can help me, please! 

2 ACCEPTED SOLUTIONS
Alef_Ricardo_
Resolver II
Resolver II

Hello x-datita! I see that you are having trouble with formatting your measures in Power BI. One way to solve this issue is by using dynamic format strings for measures. This feature allows you to use a DAX expression to determine the format string that a measure will use1. To use this feature, you need to go to File > Options and settings > Options > Preview features and check the box next to Dynamic format strings for measures1. Once you have enabled this feature, you can add a dynamic format string to a measure by clicking on the measure in the Data pane, then going to the Measure tools ribbon, expanding the Format list box, and choosing Dynamic2. A new list box should appear to the left of the DAX formula bar with Format selected. This list box is how you can switch between the measure DAX expression and the dynamic format string DAX expression2. You can then overwrite the pre-populated string with whatever DAX expression will output the desired format string for your measure1.

View solution in original post

v-binbinyu-msft
Community Support
Community Support

Hi @x-datita ,

Please use below dax formual for the measure dynamic format(Create dynamic format strings for measures in Power BI Desktop - Power BI | Microsoft Learn)

 

VAR tmp =
    SELECTCOLUMNS ( Medida, "Media", [Medida] )
VAR _str =
    CONCATENATEX ( tmp, [Media] )
RETURN
    SWITCH ( _str, "Sales", "$#,0.00", "Quantity", "#,0.00" )

 

vbinbinyumsft_0-1692241457412.png

vbinbinyumsft_1-1692241490072.png

Result:

vbinbinyumsft_2-1692241583575.png

vbinbinyumsft_3-1692241613246.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-binbinyu-msft
Community Support
Community Support

Hi @x-datita ,

Please use below dax formual for the measure dynamic format(Create dynamic format strings for measures in Power BI Desktop - Power BI | Microsoft Learn)

 

VAR tmp =
    SELECTCOLUMNS ( Medida, "Media", [Medida] )
VAR _str =
    CONCATENATEX ( tmp, [Media] )
RETURN
    SWITCH ( _str, "Sales", "$#,0.00", "Quantity", "#,0.00" )

 

vbinbinyumsft_0-1692241457412.png

vbinbinyumsft_1-1692241490072.png

Result:

vbinbinyumsft_2-1692241583575.png

vbinbinyumsft_3-1692241613246.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you!!

It works very well

Alef_Ricardo_
Resolver II
Resolver II

Hello x-datita! I see that you are having trouble with formatting your measures in Power BI. One way to solve this issue is by using dynamic format strings for measures. This feature allows you to use a DAX expression to determine the format string that a measure will use1. To use this feature, you need to go to File > Options and settings > Options > Preview features and check the box next to Dynamic format strings for measures1. Once you have enabled this feature, you can add a dynamic format string to a measure by clicking on the measure in the Data pane, then going to the Measure tools ribbon, expanding the Format list box, and choosing Dynamic2. A new list box should appear to the left of the DAX formula bar with Format selected. This list box is how you can switch between the measure DAX expression and the dynamic format string DAX expression2. You can then overwrite the pre-populated string with whatever DAX expression will output the desired format string for your measure1.

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.

Top Solution Authors