How to conditional format a KPI in Power BI

Shashanka Shekhar
Microsoft Power BI
Published in
3 min readMar 13, 2024

Power BI is a platform that allows you to connect to various data sources, transform and model your data, and create interactive dashboards and reports. Power BI can help you gain insights from your data and communicate them effectively.

What is Conditional Formatting in Power BI?

Conditional formatting in Power BI is a powerful feature that allows you to visually enhance and customize the appearance of your data based on certain conditions or rules1. It lets you apply different styles, colors and formats to your data to make it stand out and convey important insights more effectively.

Photo by Markus Winkler on Unsplash

Building the Conditional Formatted KPI

We will be making this KPI:

Conditional Formatted YoY Profit KPI

We will be conditional formatting the YoY Profit KPI, if the percentage is positive then the background will be green if its negative then red. To make YoY KPI refer this article, it’s short and easy.

1.DAX for Conditional Formatting:

Now we want the YoY Profit to Green or Red colour depending on the YoY Profit value for which we will use a DAX:

Profit Colour = IF([YoY Profit]>0,”Green”,”Red”)

DAX to give colour

Its simple, IF YoY Profit>0 then Profit Colour = Green and if IF YoY Profit<0 then Profit Colour = Red.

Select YoY Profit and in Visualizations head to Format visual then to General expand Effects then turn on Background and in Color press fx.

General settings

In Format style choose Rules and in field select Profit Colour. Now in Rules type Green in the same way as you wrote in the IF function of the Profit Colour following the if values is portion and choose green colour(Hex Code #149B26) then add another rule by pressing +New rule and type Red following the if values is portion and again in the same way as in IF function then just choose red colour(Hex Code #A1343C).

This is how the Rules should look

With this we are done, similarly you can conditional format other elements in Power BI too.

The Final Conditional Formatted KPI

To create MoM KPI refer to this link.

To create PMTD Sales KPI refer to this link.

To create MTD Sales KPI refer to this link.

To create PYTD Sales KPI refer to this link.

To create a multi conditioned SWITCH function refer to this link.

To read more stories like this you can follow me with this link.

Don’t forget to subscribe to

👉 Power BI Publication

👉 Power BI Newsletter

and join our Power BI community

👉 Power BI Masterclass

--

--

Shashanka Shekhar
Microsoft Power BI

Contributor for Microsoft Power BI. I like Data Analysis and Data Science. Also I enjoy sports, videogames and Japanese Anime in my free time.