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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.