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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
CG_FinXO
Regular Visitor

Changing Card Colour based on Date Condition

Hello,

 

I'm relatively new to Power BI and am looking to create a rule that changes the colour of a card in power BI, if the value is over x age (for example if the date/ time value is over 1 week old, then the card turns red). 

 

I have tried using the 'card with states' add on, but this only allows for less than or greater than, not a conditional option such as 'less than 1 week'. 

 

Would really appreciate if anyone could help!

 

 

1 ACCEPTED SOLUTION

IsWithinLast7Days = IF(MAX('YourTable'[DateColumn]) >= TODAY() - 7 && MAX('YourTable'[DateColumn]) <= TODAY(), "1", "0")

Use above measure for conditional formatting and set rules for same
if measure value is 1 then set color to red, similarly for 0.

View solution in original post

6 REPLIES 6
Dhairya
Super User
Super User

Hey @CG_FinXO 
To achieve this functionality you can create measure that returns 1(less than 1 week) and 0(more than 1 week) and then you can add rule in conditional formatting of Card.


If this helps you please mark my solution as accepted !

Hi Dhairya,

 

Thank you for your response! I created the measure using your instructions, but when I add the measure to the field where the date is also being pulled from, I recieve 'can't display visual'. 

 

Would you be able to elaborate a bit more on how you would add this into the 'card with states' visual?

 

Thank you!

Hey
You don't have to plot that measure on visual, just use that measure for conditional formatting, and apply rule for same that if the output of your measure is 1(less than 1 week) then color it red.

If still you are facing issue please share your sample dataset and measure you created.

HI Dhairya,

 

I'm not 100% on the correct input for the measure. I've included an example of the data and fields below:

 

CG_FinXO_0-1687267262819.png

 

IsWithinLast7Days = IF(MAX('YourTable'[DateColumn]) >= TODAY() - 7 && MAX('YourTable'[DateColumn]) <= TODAY(), "1", "0")

Use above measure for conditional formatting and set rules for same
if measure value is 1 then set color to red, similarly for 0.

Thank you for all your help!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.