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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Conditional Formatting based on another Field Value

Hello,

I am having some issues with conditional formatting and maybe the more experienced users here can give me a hint in the right direction.

 

Data

A list of dates, categorized by project and department. Every date also has a status, in the example here "Finished" and "Planned".

Example Data

Screenshot 2021-01-28 153410.jpg

 

Visual

A table that displays the latest date for each project and department. The dates should be colored according to their status, i.e. Finished is green and Planned is orange. In the real data there are more options for status.

Screenshot 2021-01-28 153532.jpg

 

I tried simply solving it with some columns that list the color and then assigning the field color based on that field. But this doesn't work, because I need to choose a summarization for the field values, either First or Last, which just sorts the color names alphabetically insted of using the the one next to the field. (I changed Orange to Gold because it accidently displayed the correct result.)

Screenshot 2021-01-28 153652.jpg

Screenshot 2021-01-28 153734.jpg

 

Is there a way to get a measure that returns the correct color?

 

Edit: Added link to example data

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You have to create color measures like this one and use them in conditional formatting with "Field value" option

 

measure =
var _max = calculate(max(Table[status]), filter(Table, table[project] = max(Table[project]) && table[Department] = max(Table[Department]) && Table[Date1] =[latest date 1]))
return
if(_max= "Finished", "green", "red")

 

 

refer for steps

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , You have to create color measures like this one and use them in conditional formatting with "Field value" option

 

measure =
var _max = calculate(max(Table[status]), filter(Table, table[project] = max(Table[project]) && table[Department] = max(Table[Department]) && Table[Date1] =[latest date 1]))
return
if(_max= "Finished", "green", "red")

 

 

refer for steps

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Anonymous
Not applicable

Hi @amitchandak,

your solution works flawlessly. After retracing the formula step by step, I think that I now understand the capabilities of DAX measures much more, so thanks a lot for that!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.