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

The Fabric community is upgrading! Read all of the details including the timeline and what you can expect. Learn more

Reply
Anonymous
Not applicable

Conditional Formatting

Little Help here, Im using one Measure in a matrix table (CRR = Retention %) and looking at the 2022 CRR and 2021 CRR with Year in the column portion of my table. I want to use conditional formatting to highlight 2022 CRR % only, red = less than PY and green = higher than PY.  I wrote a dax measure that I thought was going to do this but 2021 is showing up red and 2022 is showing up green and the logic is wrong. When I go to delete "red" from the DAX formula, 2022 is all green no matter if its less or greater than 2021. 

 

Code 

DeGiacomo72_0-1645729949910.png

Table Output (with green and red):

DeGiacomo72_1-1645729992684.png

Table Output (just green): 

DeGiacomo72_2-1645730191287.png

(SEE EITL JUST GREEN FOR ERROR) 

 

The second table output would be correct if EITL 2022 would have shown up red. 

 

 

1 ACCEPTED SOLUTION
AllisonKennedy
Community Champion
Community Champion

@Anonymous  Logic wise I would try something like:

 

Color Measure = 

VAR _CurrentYear = YEAR(TODAY())

VAR _CYmeasure = [Measure]

VAR _PYmeasure = [PYmeasure] -- CALCULATE( [Measure] , DATEADD(Date[Date], -1, YEAR) )

RETURN

IF(  YEAR( Date[Date] ) = _CurrentYear, 
IF ( _CYmeasure > _PYmeasure, "Green", "Red")
)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
AllisonKennedy
Community Champion
Community Champion

@Anonymous  Logic wise I would try something like:

 

Color Measure = 

VAR _CurrentYear = YEAR(TODAY())

VAR _CYmeasure = [Measure]

VAR _PYmeasure = [PYmeasure] -- CALCULATE( [Measure] , DATEADD(Date[Date], -1, YEAR) )

RETURN

IF(  YEAR( Date[Date] ) = _CurrentYear, 
IF ( _CYmeasure > _PYmeasure, "Green", "Red")
)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Community Champion
Community Champion

@Anonymous  Your screenshot is small, can you please paste the DAX code direct into a post here?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

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.