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

Using an IF statement to select a percentage or decimal but retain the formatting

I have three measures
Measure 1: a growth measure expressed as a percentage
Measure 2: a sales measure expressed in $
Measure 3: an if statement that works out if to show measure 1 or measure 2 based on a slicer. 

 

Ultimately I use a slicer to determine whether to show sales or growth. 

 

The issue is that the formatting on measure 3 is what applies to the output rater than respecting the formatting of measure 1 or 2. I can see why this would be the ideal case but it isn't great for me.

 

At the moment I have measure 3 set as a decimal number so the growths are expressed as a decimal (0.2 for 20%).

I understand I can add FORMAT(Measure2,"0%") however then the output is as text and I cannot put it on a graph.

 

Has anyone any ideas on how to have measure 3 show a percentage that can be graphed or a $ that can be graphed based on where the if statement comes from?

 

The goal here is to enable users to use a slicer that will change the chart to show the sales as a line or the growth as a line. 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @User7664 

You can use calculation Groups to do this.  @MattAllington  has written about it here

Dynamic Formatting of Switch Measures - Excelerator BI

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @User7664 ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it.

 

Best Regards,
Eyelyn Qin

v-eqin-msft
Community Support
Community Support

Hi @User7664 ,

 

According to my understanding, you want to display xx% or $xx in Line chart based on selected value in slicer, right?

 

I think @PhilipTreacy has provided an effective method, or you could try this(but with some minor flaws):

 

 

Measure1= IF(MAX('ForSlicer'[Value])="growth", <condition>)
Measure2=IF(MAX('ForSlicer'[Value])="sales", <condition>)

 

Put Measure1 to Values and Measure2 to Secondary Values after changing the format in Tools pane,

and disable Y-axis:

3.16.2.secondary.gif

Here is the pbix file.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @User7664 

You can use calculation Groups to do this.  @MattAllington  has written about it here

Dynamic Formatting of Switch Measures - Excelerator BI

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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.