Conditional Formatting Based on Field Value in Power BI

In Power BI you can add conditional formatting to your tables by using hex colour code values from another column.

I prefer this method of managing your conditional formatting for two reasons. Its quicker to set up rather than using the colour scale form, and the column can be re-used.

In this example I’ve created a measure with the following DAX using the SWITCH function.


Profit Target Colour = 
SWITCH(
    TRUE,
    SUM([Profit]) > 2000000, "#adebad",
    SUM([Profit]) > 1000000, "#ffff80",
    "#ff8080"
    )

Now in your table or matrix you can add the conditional formatting by selecting the drop down arrow of the value field you wish to format. In my example its [Profit]. You then go Conditional Formatting > Background Color.

In the Background color form you want to select Field value in the Format by and then in the drop down find your newly created measure.

You’ll then get a result in your table or matrix like below.

This feature was released in the Power BI 2018 August release.