Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Mahieddine
New Member

Conditionnal Number Format

Good evening,

 

I'm working on a dynamic column chart which displays a specific metric depending on the option selected in a separate slicer. Here is the measure used in the Y-Axis to get this result : 

 

Y - Axis = VAR SelectedMeasure = SELECTEDVALUE('Measure Table'[Y-Axis]) RETURN SWITCH ( SelectedMeasure, "EV / EBITDA LTM", [EV / EBITDA (LTM)], "EV / EBITDA NTM", [EV / EBITDA (NTM)], "EV / Industry Metric", [EV / Industry Metric], "EV", [EV (in M$)], "Discount Rate", [Discount Rate (%)], BLANK () ).

 

Mahieddine_0-1698699564450.png

Mahieddine_1-1698699587546.png

 

The dynamic feature works fine mostly apart from one issue : The number format isn't ajusted based on the metric observed. I would like to get a chart with values in percentage when the metric chosen in the Discount Rate and with decimal values for other metrics ( see picture below, Y-Axis displayed a value of 0.12, the result achieve is 12.00% as shown by Y-Axis Spe)
 
Mahieddine_2-1698699916160.png
 
Mahieddine_3-1698699975185.png

 

 Mahieddine_4-1698700029624.png

 

The closer I got to achieving the result wanted was through the measure Y-Axis Spe and Formatted Y - Axis. The measures works on Tables but for some reason, it doesn't work on column charts. 

 

Mahieddine_5-1698700207596.png

Mahieddine_7-1698700556808.png

 

Mahieddine_6-1698700488370.png

 

How can I get a measure that can adjust the number format when a specific metric is selected in the slicer (in this case, the "discount rate") and that works on graph ?

 

I would really appreciate some help if anyone has a solution in mind.

Thank you very much!!

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Mahieddine I guess selectedvalue  is the issue, read this post to get the selected value.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

parry2k
Super User
Super User

@Mahieddine this should be your measure (in my opinion)

 

Dynamic Title - progression annuelle =
VAR SelectedValue1 =
    SELECTCOLUMNS (
        SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
        Parameter[Parameter]
    )
VAR SelectedValue2 =
    SELECTEDVALUE ( 'Comparables Database - Power BI Dashboard'[Sector] )
RETURN
    SWITCH (
        TRUE (),
        SelectedValue1 = "EV / Industry Metric",
            SWITCH (
                TRUE (),
                SelectedValue2 = "Infrastructure", "EV / MW",
                SelectedValue2 = "Agriculture", "EV / Hectare",
                "EV / Industry Metric"
            ),
        SelectedValue1 = "Discount Rate", "Discount Rate",
        SelectedValue1 = "EV / EBITDA LTM", "EV / EBITDA LTM",
        SelectedValue1 = "EV / EBITDA NTM", "EV / EBITDA NTM",
        SelectedValue1 = "EV / Revenue", "EV / Revenue",
        SelectedValue1 = "EV", "EV (in M$)"
    )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

13 REPLIES 13
parry2k
Super User
Super User

@Mahieddine this should be your measure (in my opinion)

 

Dynamic Title - progression annuelle =
VAR SelectedValue1 =
    SELECTCOLUMNS (
        SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
        Parameter[Parameter]
    )
VAR SelectedValue2 =
    SELECTEDVALUE ( 'Comparables Database - Power BI Dashboard'[Sector] )
RETURN
    SWITCH (
        TRUE (),
        SelectedValue1 = "EV / Industry Metric",
            SWITCH (
                TRUE (),
                SelectedValue2 = "Infrastructure", "EV / MW",
                SelectedValue2 = "Agriculture", "EV / Hectare",
                "EV / Industry Metric"
            ),
        SelectedValue1 = "Discount Rate", "Discount Rate",
        SelectedValue1 = "EV / EBITDA LTM", "EV / EBITDA LTM",
        SelectedValue1 = "EV / EBITDA NTM", "EV / EBITDA NTM",
        SelectedValue1 = "EV / Revenue", "EV / Revenue",
        SelectedValue1 = "EV", "EV (in M$)"
    )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you very much for your help, it work perfectly!

parry2k
Super User
Super User

@Mahieddine why you have following line in your expression:

 

RETURN IF ( COUNTROWS ( SelectedValue1 ) = 1, SelectedValue1 )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Mahieddine_0-1698707350932.png

The line was present in the code proposed in the article you shared with me, that's why I used the expression.

parry2k
Super User
Super User

@Mahieddine can you paste the actual code instead of the screen shot?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Dynamic Title - progression annuelle =
VAR SelectedValue1 =  SELECTCOLUMNS (
        SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
        Parameter[Parameter])
RETURN IF ( COUNTROWS ( SelectedValue1 ) = 1, SelectedValue1 )
VAR SelectedValue2 = SELECTEDVALUE('Comparables Database - Power BI Dashboard'[Sector])
RETURN
    SWITCH (
        TRUE (),
        SelectedValue1 = "EV / Industry Metric",
            SWITCH (
                TRUE (),
                SelectedValue2 = "Infrastructure", "EV / MW",
                SelectedValue2 = "Agriculture", "EV / Hectare",
                "EV / Industry Metric" ),
        SelectedValue1 = "Discount Rate", "Discount Rate",
        SelectedValue1 = "EV / EBITDA LTM", "EV / EBITDA LTM",
        SelectedValue1 = "EV / EBITDA NTM", "EV / EBITDA NTM",
        SelectedValue1 = "EV / Revenue", "EV / Revenue",
         SelectedValue1 = "EV", "EV (in M$)")
parry2k
Super User
Super User

@Mahieddine I guess selectedvalue  is the issue, read this post to get the selected value.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Mahieddine_0-1698705166111.png

I tried to replace the SelectedValue as shown in the article you sent me but the solution doesn't seem to work, do you have any idea why ?

Thank you again!

parry2k
Super User
Super User

@Mahieddine can you click the details and provide the error message?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Mahieddine_0-1698703740053.png

Of course, thank you for the quick reply!

parry2k
Super User
Super User

@Mahieddine there are many ways to solve this:

 

first, you can use field parameters for the measure selection rather than using a disconnected table (I assume that is what you did)

2nd, you can use dynamic format feature to change the format of the measure based on the selection, check this video on dynamic format:  

 

From Thousands to Billions: The Power of Dynamic Formatting in Power BI - April 2023 Power BI Update...

 

Tips for Dynamic Formatting in Power BI - Customize Line and Stack Column Charts | PeryTUS - Power -...

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you very much! I used the field parameters instead of my disconnected table and the number format is working perfectly. However, I got a new problem resulting from the change. The table of my graph was based on this measure :

 

Mahieddine_0-1698703242928.png

 

I adjusted it to reflect the changes I made so it can refer to the parameter chosen :

Mahieddine_1-1698703342526.png

 

But I'm getting this error after changing the title measure : 

Mahieddine_2-1698703487421.png

 

Do you know what may cause this error ?

 

Thank you very much for your help!

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.