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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
FlavioMe3101
New Member

Conditional formatting

Hello, I am facing a challenge with a business intelligence (BI) project that I am working on. The project involves displaying the expiration status of some fruits in a table.  The table has the first column as the batch of fruits and the second is the expiration date. I want to apply a conditional formatting rule to the table, such that the cells in the date column change their color based on a expiration date. Basically I want that all dates after the expiration date become colored, even when there is no data on it. How can I achieve this functionality in my BI tool?

 

Screenshot 2024-02-09 104540.jpg

1 ACCEPTED SOLUTION
PijushRoy
Super User
Super User

Hi @FlavioMe3101 

Please follow the articles that shows all options of conditional formatting 
https://blog.coupler.io/power-bi-conditional-formatting/

 

For your requirement please follow point no 4, conditional formatting with measure.
Please create a measure for Date change and use the measure as conditional formatting.


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

Thanks
Pijush
Linkedin




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





View solution in original post

4 REPLIES 4
FlavioMe3101
New Member

IT Worked!!!!!!!!  Thank you guys!!!!. all you guys help me a lot!!!!!! I really apreciate for it!!!!!!!!

Anonymous
Not applicable

Hi @FlavioMe3101 ,

 

Both @PijushRoy and @MFelix are all capable users and you can trust them! Their advice are fine, and you can accept them.

If you're a beginner and still have doubts about measures or instructional documentation, I'll provide a step-by-step process to achieve the effect on your screenshots. Take a look:

Supposing that your have a table1 has 2 columns and table2 has 3 columns as follows.

vstephenmsft_0-1707722205090.png

vstephenmsft_3-1707722905244.png

 

1.Create a calendar table to get full dates(from 1/1/2024 to 1/13/2024).

Under Modeling, click 'New table' and enter the below formula.

vstephenmsft_1-1707722488943.png

Calendar = CALENDAR(DATE(2024,1,1),DATE(2024,1,13))

vstephenmsft_4-1707723387112.png

 

2.Create a matrix visual, and put fields into it.

Measure = CALCULATE(SUM('Table (2)'[Count]),FILTER('Table (2)',[Date]=MAX('Calendar'[Date])))

vstephenmsft_5-1707723463995.png

3.Turn off the stepped layout option, you will get the expected layout.

vstephenmsft_6-1707723497169.png

4.Create another measure for conditional formatting.

Measure 2 = IF(MAX('Calendar'[Date])>=MAX('Table'[Valid]),"red")

Then the important conditional formatting is begun here.

vstephenmsft_7-1707723568493.png

vstephenmsft_8-1707723708183.png

vstephenmsft_9-1707724159733.png

As you can see, the blank cells don't have a background color, which you can fix by modifying the previous measurements. This is the modified measure.

Measure = var _value=CALCULATE(SUM('Table (2)'[Count]),FILTER('Table (2)',[Date]=MAX('Calendar'[Date])))
return IF(_value=BLANK(),"",_value)

vstephenmsft_10-1707724220735.png

Hopefully, the steps I have followed above will be helpful to your business intelligence (BI) project.

The key to success above is also the creation of relationships, which you can download my attachment to view in the model view.

 

 

Best Regards,

Stephen Tao

 

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

MFelix
Super User
Super User

Hi @FlavioMe3101 ,

 

Create a measure similar to this one:

Color format = IF(MIN(Calendar[Date]) >= SELECTEDVALUE(Table[Valid]) , "Red")

 Then use this metric has your condittional formatting.

 

I assume that the date you have on the columns comed from a calendar table or similar.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



PijushRoy
Super User
Super User

Hi @FlavioMe3101 

Please follow the articles that shows all options of conditional formatting 
https://blog.coupler.io/power-bi-conditional-formatting/

 

For your requirement please follow point no 4, conditional formatting with measure.
Please create a measure for Date change and use the measure as conditional formatting.


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.

Thanks
Pijush
Linkedin




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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