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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PuddleRunna
Advocate I
Advocate I

Conditional formatting based on years within timeframe

Hi all,

 

I'm wondering whether there's a faster/better practice approach to what I'm doing:

Basically I'm trying to create a report on a hardware lifecycle.

Lifecycle looks like this: 

Lifecycle.png

 

 

 

 

 

 

 

 

So everything within a 5year timespan is fine, anything older needs a refresh or has no support

 

My Table looks like this:

Mapping | Generation | Last Supported Build (Refresh)

X280

2018

 

L470

2017

21H2

T490

2019

 

T460

2016

20H2

P50

2014

1809

L460

2016

20H2

X250

2015

1909

 

Now what I'd like to be able to do dynamically is use conditional formatting based on where a model is in it's lifecycle, i.e. if it's within 5 Years of e.g. YEAR(TODAY()) it's green, if it's in year 6 it's amber, if it's >6 Years it's red.

 

Column Generation is set as Date (yyyy). I also have a measure for Current year = Year(TODAY()). I have created a new column as 

Aging = [Current Year]-'HW Lifecycle'[Generation] which gives me the difference, in my case values from 1-9 as 2012 is the oldest year.

 

In conditional formatting I have used this, but I'm wondering whether there's a smoother way to do this, e.g. via a measure?

 

Conditional.png

 

 

 

 

 

 

(I have a different measure foe something else that I created to be used in conditional formatting: 

Color Today = if(FIRSTNONBLANK('Waves'[Date],TODAY()) <today(),"#01B8AA","#fd817e"), so maybe there's something similar for the above scenario. I just couldn't figure it out)

 

Any tips are greatly appreciated 🙂

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @PuddleRunna ,

 

Yes,you could use below dax expression:

Color Today = if(MAX(Aging)>5&&MAX(Aging)<10,"#d10c08",
                 if(MAX(Aging)=6,"#f5e042",
                   if(MAX(Aging)>=1%&&MAX(Aging)<=5,"#63f542",Blank())))

 


Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @PuddleRunna ,

 

Yes,you could use below dax expression:

Color Today = if(MAX(Aging)>5&&MAX(Aging)<10,"#d10c08",
                 if(MAX(Aging)=6,"#f5e042",
                   if(MAX(Aging)>=1%&&MAX(Aging)<=5,"#63f542",Blank())))

 


Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Hi Kelly,

 

thanks a lot!! 🙂

Had to remove the '%' in the last line and corrected my own mistake of  ">5 <10" to ">=7 <10" (in case someone is looking for something similar and is gonna copy this)

 

It still behaves oddly for the last line, e.g. it doesn't mark lines that have an aging value of 3. But I'm sure I'll figure this out from here.

 

So thanks again!

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.