How to change the colors of your visuals based on the selected measure
- Mara Pereira
- Sep 21, 2022
- 3 min read
Updated: Dec 1, 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)
}
In the formula you can change the description that will show in your slicer (highlighted in green). You need to memorize the number for your measure (highlighted in pink) as we will be using it later:
> Orders value measure = 0
> Number of orders measure = 1
Next, we need to replace the values from our charts with this new parameter, so that when you select the measure using the slicer, this will be reflected on your charts:

Now, we are going to create a few measures that will help us with switching between different colors. First, I'm going to create a measure that will allow me to switch colors on my bar charts. The measure I used is below:
Status color =
var selected_measure = SELECTEDVALUE('Parameter 1'[Parameter 1 Order])
return
if(selected_measure= 0, "#7FB7BE", "#7A6174")
So this measure will evaluate which measure we have selected in our measures slicer and then, based on the selection, it will retrieve different HEX color codes. If the measure is 0, which means we have selected the Number of orders, then it will retrieve the hex code #7FB7BE, if not (meaning that we have the Orders Value £ selected) then retrieve the hex code #7A6174.
After creating the new measure, we need to define the conditional formatting of our bar chart colors, so that the correct color is showed depending on the measure selection:

The only thing missing now is applying some conditional formatting on the KPI cards, so that we have the KPI card "highlighted" based on the measure selected in the slicer.
To do this, I created 2 extra measures. You can have everything in the same measure, but to keep it simple I decided to build separate measures, one to change the color of the Number of orders KPI card, and another one to change the color of the Order value KPI card.
The logic I applied is the same as the measure I built to change the colors of the bar charts:
Status color Number of Orders =
var selected_measure = SELECTEDVALUE('Parameter 1'[Parameter 1 Order])
return
if(selected_measure= 1, "#7A6174", "#D5D8DC")
Status color orders value =
var selected_measure = SELECTEDVALUE('Parameter 1'[Parameter 1 Order])
return
if(selected_measure= 0, "#7FB7BE", "#D5D8DC")
We can go to our formatting pane now and apply some conditional formatting over the background color of our KPI cards:

And that's it! Now we have our report changing colors depending on the metric that we have selected in our slicer!
Pro tip
You can do something similar to switch between light mode/dark mode on your report without leaving the same report page. However, this will be a significant amount of work as you have to apply loads of conditional formatting over your charts (title color, bars color etc).
Interested in learning more about Power BI Report Design? Then the Power BI Report Design Bootcamp is for you!
Join the growing network of software engineers shaping tomorrow’s digital world through the College of Contract Management. This course teaches real-world development skills, including frontend frameworks, secure coding practices, and systems integration. You’ll study remotely with expert tutors while learning about data structures, object-oriented programming, and agile workflows. Head over to the College of Contract Management’s site to review entry requirements and student benefits.
Nasha Mukti kendra patna offers expert addiction recovery services with a caring approach. Start your journey to a healthier, addiction-free life today.
Take control of your career path in the buisness computing world. The buisness computing world needs professionals who are ready to adapt quickly and lead. The College of Contract Management’s online NCC BSc (Hons) Top-Up Degree equips you for the challenges of a dynamic work environment. Start to click through to their website and begin your enrollment process today.
<a href="https://sprinklezstrain.com/product/chokocovered-banana-marshmallow/" rel="dofollow">ChokoCovered Banana Marshmallow</a>
<a href="https://sprinklezstrain.com/product/funfetti-marshmallow/" rel="dofollow">Funfetti Marshmallow</a>
<a href="https://sprinklezstrain.com/product/raspberry-ripple-marshmallow/" rel="dofollow">Raspberry Ripple Marshmallow</a>
<a href="https://sprinklezstrain.com/product/strawberry-cheesecake-marshmallow/" rel="dofollow">Strawberry Cheesecake Marshmallow</a>
<a href="https://sprinklezstrain.com/product/rainbow-bubblegum-marshmallow/" rel="dofollow">Rainbow BubbleGum Marshmallow</a>
<a href="https://sprinklezstrain.com/product/key-lime-marshmallow/" rel="dofollow">Key Lime Marshmallow</a>
<a href="https://sprinklezstrain.com/product/blueberry-pie-marshmallow/" rel="dofollow">Blueberry Pie Marshmallow</a>
<a href="https://sprinklezstrain.com/product/marshmallow-fruit-pebble/" rel="dofollow">Fruity Pebblez Marshmallow</a>
<a href="https://sprinklezstrain.com/product/marshmallow-watermelon/" rel="dofollow">Watermelon Marshmallow</a>
<a href="https://sprinklezstrain.com/product/marshmallow-birthdaycake/" rel="dofollow">Birthdaycake Marshmallow</a>
<a href="https://sprinklezstrain.com/product/blue-mm-sprinklez/" rel="dofollow">Blue M&M Sprinklez</a>
<a href="https://sprinklezstrain.com/product/marshmallow-super-duper/" rel="dofollow">Marshmallow Super Duper</a>
<a href="https://sprinklezstrain.com/product/marshmallow-froot-loopz/" rel="dofollow">Marshmallow Froot Loopz</a>
<a href="https://sprinklezstrain.com/product/gumdropz-concord-grape/" rel="dofollow">Gumdropz Concord Grape</a>
<a href="https://sprinklezstrain.com/product/sprinklez-gumdropz/" rel="dofollow">Sprinklez Gumdropz</a>
<a href="https://sprinklezstrain.com/product/gumdropz-poppin-papaya/" rel="dofollow">Gumdropz poppin papaya</a>
<a href="https://sprinklezstrain.com/product/gumdropz-mango-mayhem/" rel="dofollow">Gumdropz Mango Mayhem</a>
<a href="https://sprinklezstrain.com/product/gumdropz-wacky-watermelon/" rel="dofollow">Gumdropz Wacky Watermelon</a>
<a href="https://sprinklezstrain.com/product/gumdropz-island-punch/" rel="dofollow">Gumdropz Island Punch</a>
<a href="https://sprinklezstrain.com/product/gumdropz-strawberry-splash/" rel="dofollow">Gumdropz Strawberry Splash</a>
<a href="https://sprinklezstrain.com/product/gumdropz-berry-bonanza/" rel="dofollow">Gumdropz Berry Bonanza</a>
<a href="https://sprinklezstrain.com/product/gumdropz-wild-berry/" rel="dofollow">Gumdropz Wild Berry</a>
<a href="https://sprinklezstrain.com/product/torchiez-blazin-banana/" rel="dofollow">Torchiez Blazin Banana</a>
<a href="https://sprinklezstrain.com/product/torchiez-red-hotz/" rel="dofollow">Torchiez Red Hotz</a>
<a href="https://sprinklezstrain.com/product/torchiez/" rel="dofollow">Original Torchiez</a>
<a href="https://arborshroom.com/product/buy-polkadot-magic-mushroom/" rel="dofollow">PolkaDot Magic Mushroom Shots 4g</a>
<a href="https://arborshroom.com/product/polkadot-blueberry-muffin-mushroom-chocolate/" rel="dofollow">Polkadot Blueberry Muffin Belgian mushroom Chocolate</a>
<a href="https://arborshroom.com/product/magic-mushroom-chocolate-bars/" rel="dofollow">PolkaDot Acai Magic Mushroom Chocolate</a>
<a href="https://arborshroom.com/product/polkadot-dragonfruit-near-me/" rel="dofollow">Dragonfruit Lemonade</a>
<a href="https://arborshroom.com/product/buy-polkadot-blueberry-muffin/" rel="dofollow">Polkadot Blueberry Muffin</a>
<a href="https://arborshroom.com/product/polka-dot-berries-cream/" rel="dofollow">Polka Dot Berries & Cream</a>
<a href="https://arborshroom.com/product/polka-dot-chocolate-coconut/" rel="dofollow">POLKA DOT CHOCOLATE COCONUT</a>
<a href="https://arborshroom.com/product/lsd-vial-liquid-lsd/" rel="dofollow">LSD Vial (Liquid LSD)</a>
<a href="https://arborshroom.com/product/lsd-acid-200-ug-buy-lsd-acid-200-ug-online/" rel="dofollow">LSD ACID 200 Ug – Buy LSD ACID 200 Ug Online</a>
<a href="https://arborshroom.com/product/buy-soulcybin-ceremonial-blend-the-journey-online/" rel="dofollow">Ceremonial Blend – “The Journey”</a>
<a href="https://arborshroom.com/product/buy-adaptogen-blend-alignment-online/" rel="dofollow">Brain Booster – “Mental Mastery”</a>
<a href="https://arborshroom.com/product/buy-soulcybin-adaptogen-blend-alignment-online/" rel="dofollow">Buy Soulcybin Adaptogen Blend “Alignment”</a>
<a href="https://arborshroom.com/product/buy-soulcybin-100-syrian-rue-the-amplifier-online/" rel="dofollow">Soulcybin 100 % Syrian Rue “The Amplifier”</a>
<a href="https://arborshroom.com/product/infinite-rx-absorb-microdosing-psilocybin-capsules-2/" rel="dofollow">Buy INfinite Rx (Absorb) Microdosing Psilocybin Capsules</a>
<a href="https://arborshroom.com/product/be-youthful-booster-mushroom-supplement-capsules-2/" rel="dofollow">Buy Be Youthful (Booster) online</a>
<a href="https://arborshroom.com/product/buy-mushroom-supplement-capsules/" rel="dofollow">Buy Mushroom Supplement Capsules</a>
<a href="https://arborshroom.com/product/cordyceps-mushroom-gummies/" rel="dofollow">Cordyceps Mushroom Gummies</a>