Forum Discussion
Dax for Dates RAG Status
Hello Everyone,
I am looking to add conditional formatting to a date column to highlight due dates using Red, Abber and Green.
My date column is called 'Cancellation Date'. I would like to highlight dates as follows:
Anything due before today = Red
Anything due in the next 6 months = Amber
Anything due in more than 6 months = Green
Any assistance would be much appreciated.
hi, AMBP1973
try below codeoutput =var a = DATEDIFF(TODAY(),MAX('rag'[date]),MONTH)var b =SWITCH(TRUE(),a<=0,"#FF0000",a<=6&& a>0,"#FFBF00",a>6,"#00FF00")returnbHere you get only red and green combination becuase in your data which you provide none of date lies bw 0 to 6 month .i already calculate measurte which indicate difference bw today and due dateIf this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos
9 Replies
- Dangar332Resident Rockstar
- AMBP1973Helper III
Hi Dangar332 . I just thought this could be acheived as I have seen it in a simular question before, but it wasn't quite what I was after. As listed in my question this would be based on a date column called 'Cancellation Date'. I would like to highlight dates as follows:
Anything due before today = Red
Anything due in the next 6 months = Amber
Anything due in more than 6 months = Green
Thankyou in advance
- Dangar332Resident Rockstar
hi , AMBP1973
try below Dax code and adjust your table and column name
output =var a = DATEDIFF(TODAY(),MAX('Table'[Column1]),MONTH)returnSWITCH(TRUE(),a=0,"#FF0000",a<=6,"#FFBF00",a>6,"#00FF00")follow below stepchane gradient to field value
choose your measure name and press ok.
you get your result.
refer Here to download pbix. file of your requirnment.If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos.