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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
E_K_
Helper III
Helper III

SELECTEDMEASURE so that the same colour format can be used on several measures at once

Hi guys

 

I'm in a difficult spot. A lot of my work is trend based and the colour formatting based on trends is dependent on specific rules. For context, I have hundreds of formatting measures for each specific measure - it comes to the point that there is a formatting measure for every single trend measure that I have and it's getting unmangeable to have so many.

 

I'm trying to get this measure to work but it won't. I've tried creating the same in tabular editor but is doesn't work - i either case when I format the visual by this measure it won't work. I have the same across specific ones as well that match the measure I am trying to apply the format to. 

 

General measure (aim): 

Incident Trend Flexi Colours =
    VAR TextValue = FORMAT(SELECTEDMEASURE(), "General Number")
     RETURN
         IF(
        CONTAINSSTRING(TextValue, "from 0"), "#D90400",
        IF(TextValue = "-", "#000000",
            IF(TextValue = UNICHAR(11165), "#000000",
                IF(VALUE(TextValue) > 0.15, "#D90400",  
                    IF(VALUE(TextValue) > 0, "#DBB205",
                        IF(VALUE(TextValue) <= -0.2, "#007AC9",  

                            IF(VALUE(TextValue) <= 0, "#048119", "#D90400")
                        )
                    )
                )
            )
        )
    )
 
Specific will have SELECTEDMEASURE() replaced with the measure name - but that is exactly what I want to avoid. Specific works of course but I can't stand making even more measures! 
2 REPLIES 2
Anonymous
Not applicable

Hi @E_K_ ,

Please update the formula of measure as below and check if that can get the expected result... Please note that this formula will work only if a measure is selected in the context where this formula is being evaluated. If no measure is selected, SELECTEDMEASURE() will return an error...

Incident Trend Flexi Colours =
VAR TextValue =
    FORMAT ( SELECTEDMEASURE (), "General Number" )
RETURN
    SWITCH (
        TRUE (),
        CONTAINSSTRING ( TextValue, "from 0" ), "#D90400",
        TextValue = "-"
            || TextValue = UNICHAR ( 11165 ), "#000000",
        IFERROR ( VALUE ( TextValue ), 0 ) > 0.15, "#D90400",
        IFERROR ( VALUE ( TextValue ), 0 ) > 0, "#DBB205",
        IFERROR ( VALUE ( TextValue ), -0.1 ) <= -0.2, "#007AC9",
        IFERROR ( VALUE ( TextValue ), 0.1 ) <= 0, "#048119",
        "#D90400"
    )

Best Regards

Thanks for trying - this doesn't work. Same as last measure, no colour formatting shows up when you apply it to the visualisation in the visualisation pane within the context it's supposed to work.

 

Can anyone else help?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors