cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Dynamically change measure's format in visual (line chart) using switch?

I have a line chart that I am using a switch statement to select two different groups of measures. One is a whole number and the other is in currency. 

 

Is there a way to have the chart automatically change to currency when a measure is selected that should be in currency and switch back? 

 

Here's my measure. 

Select =
IF (
HASONEVALUE ( _Daily[Sort] ),
SWITCH ( VALUES ( _Daily[Sort] ), 1, ( [Orders $] ), 2, [Orders #] )
)

1 ACCEPTED SOLUTION
Community Support
Community Support

@sublog 

 

Format cannot be changed in a DAX measure. But you may drag both measures to Values and let one of the two return BLANK () based on the selection.

Community Support Team _ Sam Zha
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

4 REPLIES 4
Community Support
Community Support

@sublog 

 

Format cannot be changed in a DAX measure. But you may drag both measures to Values and let one of the two return BLANK () based on the selection.

Community Support Team _ Sam Zha
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

Would you mind explaining a bit more what you mean by this? How do I make one of the two measures return blank(), when the other is selected? 

Super User IV
Super User IV

Use the FORMAT() function like this

 

Format Test = var tempsum = SUM('Table 2'[Value])
return if(tempsum>5, FORMAT(tempsum, "Currency"), FORMAT(tempsum, "Percent"))
 
You can adapt for your measures.  There are pre-defined ones (like above or you can do custom).
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


I tried this, but I can't figure out how to make it show in the line chart visual. It won't even allow me to move the measure to the Values. 

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors