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

Show percentage format in a measure with switch

Hello guys, I'm having problems to show the right format in a measure with switch.

 

From a filter, I have to choose if to show my measure as a sum or as a percentage.

 

this is the measure I've created:

Selection = var selection = SELECTEDVALUE('Switch'[ID]) return Switch(TRUE();selection = 2; [sum]; selection = 1; [division])

where Switch is a table I have created to make my selection in a filter


This table is made by two columns:
Selection               - ID
---------------------
Sum                       - 2
Percentage            - 1

 

So, if a click on Sum the measure [sum] should be shown. Otherwise, the measure [division]

Both measures have been formatted individually--> [sum] as a decimal number and [division] as a percentage (so, two 0s after the comma and % symbol in my example)

ISSUE: the format for the measure [division] doesn't work!!

 

I tried FORMAT([divsion]; "#0,00%") but it doesn't work since FORMAT returns a text and it cannot be used in a line chart, which is my final goal.

Any ideas? I hope my explanation was clear.

 

Thank you so much!

5 REPLIES 5
Highlighted
Super User IV
Super User IV

Re: Show percentage format in a measure with switch

Right, this has come up a few times recently and not sure there is always an answer for how to accomplish it. You have specified the format for your other two measures, but the third measure also has a specified format so that is the one that takes precedence and you cannot flip between different formats in a single measure other than using FORMAT. You might take a look at CONVERT.


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Community Champion
Community Champion

Re: Show percentage format in a measure with switch

@MCacc -

I think your ask is very much similar to the Calculation Groups in Azure Analysis Service. Click here 
Unfortunately, we cannot define calculation groups in Power BI. This requirement is already listed in the ideas sections. You can vote.  https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/37146049-support-creating-calcula... 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

Highlighted
Community Support
Community Support

Re: Show percentage format in a measure with switch

Hi,

 

Please try divide measure like this:

Divide = FORMAT([division],"Percent")

Hope this helps.

 

Best Regards,

Giotto

Highlighted
Helper I
Helper I

Re: Show percentage format in a measure with switch

Thank you very much for your suggestion. Unfortunately, CONVERT doesn't work either. I guess I'll have to find another way to work around it 🙂

Highlighted
Community Support
Community Support

Re: Show percentage format in a measure with switch

Hi,

 

I think you can easily define one single measure custom fotmat in Model pane.

But in this case, it is impossible to define two different custom formats for one single measure based on slicer selected but only by format function. And format function will convert data to text which you do not want.

You can create an idea here:

https://ideas.powerbi.com/forums/265200-power-bi-ideas 

 

Best Regards,

Giotto

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors