Forum Discussion
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!
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.
6 Replies
- CG_FinXORegular Visitor
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!
- DhairyaSolution Supplier
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.