How to change the colors of your visuals based on the selected measure — Power BI

Data Pears
4 min readNov 2, 2022

Have you ever wondered how people do the trick below?

Say no more!

I’m going to share with you all the tricks that you need to do to achieve something like this.

In my example, I created a report where you could switch the measure the charts were showing, and with that, the color of the charts and KPI cards changed to.

The first thing you need to do is create your base measures. In my example my base measures were:

Number of Orders = count(Amazon[Order ID])Orders Value £ = SUM(Amazon[Amount])

I only used two measures, but you can have more measures if you want to.

The next step is to create a field parameter, that will allow you to switch between the two measures:

My parameter formula looks like this:

Parameter 1 = {
("Orders Value £", NAMEOF('Amazon'[Orders Value £]), 0),
("Number of Orders", NAMEOF('Amazon'[Number of Orders]), 1)
}

--

--