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
billuran
Helper I
Helper I

Formatting Numbers in Switch Dax to show up in chart

Hello All, I have a slicer that switches between dollars and units for a measure. Here is the Dax

 

Payment Selection = if(ISCROSSFILTERED(MeasureType[Units]),
SWITCH( True(),
VALUES(MeasureType[Units]) = "Count", format([Total Payments],"0,000")
VALUES(MeasureType[Units]) = "Dollars", format([Total Payment$],"$0,000")
BLANK()),[Total Payments])
 
However If i try to format each meausre it does not show up in chart. Maybe because its a text? 
I want to be able to Show in a chart $0,000 if dollars is selected and whole number if count is selected. Is this possible?
5 REPLIES 5
v-eqin-msft
Community Support
Community Support

Hi @billuran ,

Did I answer your question? Please mark my reply as solution, thank you~

Hi Unfortunetly it does not work still as it will not show up in a graph like a bar or line chart as it is presented as a string. Any ideas how to fix?

v-eqin-msft
Community Support
Community Support

Hi @billuran ,

According to my understanding, you want to dynamically display the formatted value based on slicer, right?

Here are my data sample:

8.20.4.1.PNG

You could use the following formula:

Total Payments =
FORMAT ( SELECTEDVALUE ( Pay[Payment] ), "0,000" )
Total Payment$ =
FORMAT ( SELECTEDVALUE ( Pay[Payment] ), "$0,000" )
Payment Selection =
SWITCH (
    SELECTEDVALUE ( 'MeasureType'[Units] ),
    "Count", [Total Payments],
    "Dollars", [Total Payment$]
)

My visualization looks like this:

8.20.4.2.png

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

 

FrankAT
Community Champion
Community Champion

Hi @billuran 

use the external tool tabular editor. Take a look at the following link:

https://www.kasperonbi.com/dynamic-formatstrings-with-calculation-groups/

 

Regards FrankAT

see my update. This wont show up in a  chart still.

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.