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
Anonymous
Not applicable

Switch between different measures on graph formatting

I've have a clustered column chart and the following measure:

RevenueCash_Pct Switcher2 = SWITCH([Selection3],1,[Revenue],2,[Revenue_Cash])
 

that allows me to switch between a dollar view and percentage view with a slicer at the top of the page. However, whenever I try and format these, the graph doesn't show anything.

 

RevenueCash_Pct Switcher2 = SWITCH([Selection3],1,FORMAT([Revenue],"0.00%"),2,FORMAT([Revenue_Cash],"$0,000"))
image1.PNGimage2.PNG
3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Here we can create two measures instead of a combined one to work around and format the two measures in the Modeling pane. One for percentage format and one for currency format.

 

doll = var sel = SELECTEDVALUE('Table'[Value])
var _sum = CALCULATE(SUM('Table'[Value]),ALL('Table'))
return
IF(sel=2,_sum,BLANK())
percent = var _min = CALCULATE(MIN('Table'[Value]),ALL('Table'))
var _max = CALCULATE(MAX('Table'[Value]),ALL('Table'))
var sel = SELECTEDVALUE('Table'[Value])
return
IF(sel=1,_min/_max,BLANK())

 

2.PNG

 

In your scenario, I thin you should create two measure like this.

 

RevenueCash_Pct Switcher1 = if([Selection3]=1,[Revenue],BLANK())
RevenueCash_Pct Switcher2 = IF (Selection3]=2,[Revenue_Cash],BLANK())

 

Also please find the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @Anonymous ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.


Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
yelsherif
Resolver IV
Resolver IV

The FORMAT function turns the value into text, so the chart cannot interpret the text in this case.

However, you can change the way the logic works.

You can first prepare 2 series to be used, one for the dollar value and another for the percentage, e.g.
A) myValue = if([Selection3] = 1,0,myTable[ValueToBeUsed]) then set the format from Modeling tab to currency > USD

B) myValue% = if([Selection3]=1,myTable[ValueToBeUsed],0) and keep it unformatted

 

In the chart series add series A as it is, and add series B as a percent from grand total

 

When you make a selection to Selection3, the logic of each measure will either show the value or return 0, so only one series will be shown.

 

You can adjust the percent format from modeling tab to set how many decimal points you want

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.