Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
IPGeorgiev
Helper III
Helper III

Advanced Conditional Formatting based on Variable

Hi All,

 

I have a bit complex goal I want to achieve, not sure if its possible at all.

 

Here a pbix file: https://drive.google.com/file/d/1BOvuaF2RGc0NGvtAtxae2He2nyVE5hOT/view?usp=sharing 

 

So in general in the CSAT table we have data which we use to calculate CSAT%. Then I want to create a matrix as the one in the pbix file.

 

So it has as rows Month and then Channel. Then as value we will have the respective CSAT% for the given Month&Channel.

 

For each Month&Channel we have a different goal and different network result - those are visible in the table targets.

 

So I want to apply the following logic:

 

IF -  Network Result < CSAT% < Target  - have a yellow background

IF - CSAT%<Network Results&Target - Red background 

IF - CSAT%> from both Target & Network - Green background.

 

So here the target and network results will be variables taken from the Targets table based on the month and channel. 

 

Would you be able to help on this one?

 

Many, many thanks in advance!!

 

Best regards,

Ivan

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@IPGeorgiev 

I made a few tweaks to your model.

  • Added a date table that can be used to filter both CSAT and Targets
  • Replaced the Channels table with one generated from the data so all the Channels will always be in there.

jdbuchanan71_0-1617383531355.png

Then I added some measures to use for Network and Target.

Max CSAT Network = MAX ( Targets[CSAT Network] )
Max CSAT Target = MAX ( Targets[CSAT Target] )

And those we can use in the formatting measure

Format = 
VAR _csat = [CSAT%]
VAR _network = [Max CSAT Network]
VAR _target = [Max CSAT Target]
RETURN
SWITCH(
    TRUE(),
    _network < _csat && _csat < _target, "#F9D087", --yellow
    _csat < _network && _csat < _target, "#F78272", --red
    _csat > _network && _csat > _target, "#84C28A" --green
)

This measure then gets used to set the background conditional format for each of the columns.

jdbuchanan71_1-1617384298701.png

I only applied it to the first column in my example:

jdbuchanan71_2-1617384343210.png

I have attached my update of your file for you to look at.

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

@IPGeorgiev 

I made a few tweaks to your model.

  • Added a date table that can be used to filter both CSAT and Targets
  • Replaced the Channels table with one generated from the data so all the Channels will always be in there.

jdbuchanan71_0-1617383531355.png

Then I added some measures to use for Network and Target.

Max CSAT Network = MAX ( Targets[CSAT Network] )
Max CSAT Target = MAX ( Targets[CSAT Target] )

And those we can use in the formatting measure

Format = 
VAR _csat = [CSAT%]
VAR _network = [Max CSAT Network]
VAR _target = [Max CSAT Target]
RETURN
SWITCH(
    TRUE(),
    _network < _csat && _csat < _target, "#F9D087", --yellow
    _csat < _network && _csat < _target, "#F78272", --red
    _csat > _network && _csat > _target, "#84C28A" --green
)

This measure then gets used to set the background conditional format for each of the columns.

jdbuchanan71_1-1617384298701.png

I only applied it to the first column in my example:

jdbuchanan71_2-1617384343210.png

I have attached my update of your file for you to look at.

 

You are genius!!! Many, many thanks!

amitchandak
Super User
Super User

@IPGeorgiev , You can create a complex color measure and use that in conditional formatting using field value option

 

example

 

color =
switch ( true(),
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity1" && sum('Table'[Value]) >500,"lightgreen",
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity2" && sum('Table'[Value]) >1000,"lightgreen",
// Add more conditions
"red"
)

 

refer my video for steps : https://www.youtube.com/watch?v=RqBb5eBf_I4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors