Forum Discussion

E_K_'s avatar
E_K_
Icon for Helper III rankHelper III
2 years ago

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

  • Anonymous's avatar
    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

    • E_K_'s avatar
      E_K_
      Icon for Helper III rankHelper III

      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?