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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculated Column for Colour Rule

Hi Experts

 

Need a DAX measure as a calculated column to work out the following rule inorder to colour a bar chart visual, here is the rule

1. Todays Date is 10.11.21 < then todays date "red",
2. Next month ie Dec 21 "Amber", When we are in Dec 21 Then Jan 22 is Amber only and so on

3. Any date in the future excluding next month ie Dec 21 (which would be Amber as per point 2) "Green"

 

https://www.dropbox.com/s/bwxvb5wilqrqlge/Sample_File.pbix?dl=0 

 

the measure i have and is not working is

a measure =

Switch(true() ,

max('Date'[Date]) < Today() , "Red",

max('Date'[Date]) < eomonth(Today(),1) , "Amber",,

"Green"

)

 

 

1 ACCEPTED SOLUTION

With conditional formatting for tables in Power BI Desktop, you can specify customized cell colors, including color gradients, based on field values. You can also represent cell values with data bars or KPI icons, or as active web links. You can apply conditional formatting to any text or data field, if you base the formatting on a field that has numeric, color name or hex code, or web URL values.

 

Suggested Article: Easy Steps To Generate Interactive Power BI Reports

View solution in original post

7 REPLIES 7
v-xiaoyan-msft
Community Support
Community Support

Hi @dynamicssquare ,

 

Does the replies above solve your problem? If it has been solved, please mark the correct reply as the standard answer to help the other members find it more quickly.Thanks in advance!

 

Hope it helps,


Community Support Team _ Caitlyn

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , what happen remaining nov ?

 

a measure like

 

a measure =

Switch(true() ,

max('Date'[Date]) < Today() , "Red",

max('Date'[Date]) >= eomonth(Today(),0) +1 && max('Date'[Date]) <= eomonth(Today(),1)  , "Amber",

"Green"

)

 

 

a measure =

Switch(true() ,

max('Date'[Date]) < Today() , "Red",

max('Date'[Date]) < eomonth(Today(),0)  , "Green" // remaining nov color , change that

max('Date'[Date]) >= eomonth(Today(),0) +1 && max('Date'[Date]) <= eomonth(Today(),1)  , "Amber", //dec , next month

"Green"

)

With conditional formatting for tables in Power BI Desktop, you can specify customized cell colors, including color gradients, based on field values. You can also represent cell values with data bars or KPI icons, or as active web links. You can apply conditional formatting to any text or data field, if you base the formatting on a field that has numeric, color name or hex code, or web URL values.

 

Suggested Article: Easy Steps To Generate Interactive Power BI Reports

Anonymous
Not applicable

If its nov then assume in the past.....even thow we are still in Nov and the month has not completed...

@Anonymous , try like

 

a measure =

Switch(true() ,

max('Date'[Date]) <= eomonth(Today(),0) , "Red" // less than nov

max('Date'[Date]) >= eomonth(Today(),0) +1 && max('Date'[Date]) <= eomonth(Today(),1) , "Amber", //dec , next month

"Green"

)

Anonymous
Not applicable

i Think the error is that the above is a measure and i need a calculted column

Anonymous
Not applicable

Hi Amit - Sorry to be a pain but can you implement it to the PBIX file i attached cannot get it to work...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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