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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.