Forum Discussion

cn4422's avatar
cn4422
Icon for Helper V rankHelper V
1 year ago
Solved

Switch Measure - conditional formatting

Hi,   I have several switch-measures in a matrix table, like this example here:    Switch = SWITCH(SELECTEDVALUE(Countries[Country]), "AT",DIVIDE([G AT],[L AT],0), "BE",DIVIDE([G BE],[L BE],0)...
  • bhanu_gautam's avatar
    1 year ago

    cn4422 , 

    Create a Measure for Conditional Formatting: You need to create a measure that will be used for the conditional formatting. This measure should return a value that can be used to determine the color gradient.


    ConditionalFormattingMeasure =
    SWITCH(
    TRUE(),
    SELECTEDVALUE(Countries[Country]) = "AT", DIVIDE([G AT], [L AT], 0),
    SELECTEDVALUE(Countries[Country]) = "BE", DIVIDE([G BE], [L BE], 0),
    SELECTEDVALUE(Countries[Country]) = "CH", DIVIDE([G CH], [L CH], 0)
    )


    Apply Conditional Formatting: Once you have the measure, you can apply conditional formatting to the matrix table.

    Go to the matrix visual in your Power BI report.
    Click on the dropdown arrow next to the measure you want to format.
    Select "Conditional formatting" and then "Background color" or "Font color" depending on your preference.
    In the conditional formatting dialog, choose "Field value" and select the ConditionalFormattingMeasure you created.
    Set the color scale to a three-color gradient and configure the minimum, midpoint, and maximum values as needed.