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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
leerjones85
Frequent Visitor

Help with Conditional Formatting

Afternoon all,

 

I am pretty new to Power BI and have come a bit stuck when trying to format the text colour on columns in my report table.

 

Base Table = FACT_METRICS

 

Target colour is based on the metric definition (can be different for different metrics)

 

METRICDATEACTUALTARGETTARGET_MET
METRIC 1 22/10/20241212Purple
METRIC 121/10/20248.212Green
METRIC 120/10/202412.512Red
METRIC 222/10/20246.86.5Green
METRIC 221/10/202466.5Red
METRIC 220/10/202476.5Green
METRIC 322/10/202464Red
METRIC 321/10/202434Green
METRIC 320/10/202444Green
etc...etc...etc...etc...etc...

 

Report Table looks like... (Yesterday = 22/10/2024)

 

METRICYESTERDAYDAY -2DAY -3
METRIC 1 128.212.5
METRIC 26.867
METRIC 3634
etc...etc...etc...etc...

 

I want to conditional format Yesterday, Day-2 and Day -3 font colour to equal the colour in the TARGET_MET column.

 

If I try to add condiitonal formatting to any of these columns based on rule TARGET_MET it looks for the First or Last so isnt returning the correct colour.

 

Any help is much appreciated!

 

Thank You.

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @leerjones85 

 

You could create a measure for each defining the colour to return.

The code will be similar to your yesterday or -3day code.

 

SamWiseOwl_0-1729672931712.png

Assign this as your Field value under the Background colour.

3day  Swap colour =
var day3 = CALCULATE(sum('Target Table'[ACTUAL]), 'Target Table'[DATE] = TODAY() -3)
RETURN
If(
   day3 >= CALCULATE(sum('Target Table'[TARGET]), 'Target Table'[DATE] = TODAY() -3)
    ,CALCULATE(SELECTEDVALUE('Target Table'[TARGET_MET]), 'Target Table'[DATE] = TODAY() -3)
)

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

2 REPLIES 2
SamWiseOwl
Super User
Super User

Hi @leerjones85 

 

You could create a measure for each defining the colour to return.

The code will be similar to your yesterday or -3day code.

 

SamWiseOwl_0-1729672931712.png

Assign this as your Field value under the Background colour.

3day  Swap colour =
var day3 = CALCULATE(sum('Target Table'[ACTUAL]), 'Target Table'[DATE] = TODAY() -3)
RETURN
If(
   day3 >= CALCULATE(sum('Target Table'[TARGET]), 'Target Table'[DATE] = TODAY() -3)
    ,CALCULATE(SELECTEDVALUE('Target Table'[TARGET_MET]), 'Target Table'[DATE] = TODAY() -3)
)

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Thank You! 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.