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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BulldogTom
New Member

Conditional Formatting to Conditional Column if Null Field

Hello! I would like to apply conditional formatting to a conditional column I created in Power BI Desktop but I'm stumped. I have a table with four columns.  The RTA_Current column is conditional and fills in if there is a date in RTA_Actual. The logic I'd like to apply is:

 

If RTA_Actual is not null 

Change RTA_Current background color to gray

 

If RTA_Actual is null

Change RTA_Current background color to yellow if < 30 days from today

Change RTA_Current background color to red if < Today

 

Annotation 2024-01-17 103838.jpg

Any ideas?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @BulldogTom ,

 

Here are the steps you can follow:

1. Create measure.

Color =
var _datediff=DATEDIFF(MAX('Table'[RTA Current]),TODAY(),DAY)
return
IF(
    MAX('Table'[RTA Actual])<>BLANK(),"gray",
    IF(
        MAX('Table'[RTA Actual])=BLANK()&&_datediff<30,"yellow",
        IF(
         MAX('Table'[RTA Actual])=BLANK()&&MAX('Table'[RTA Current])<TODAY(),"red"  
)))

2. [[RTA Current] – Conditional formatting – Background color.

vyangliumsft_0-1705559789865.png

vyangliumsft_1-1705559789867.png

3. Result:

vyangliumsft_2-1705559820437.png

Best Regards,

Liu Yang

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @BulldogTom ,

 

Here are the steps you can follow:

1. Create measure.

Color =
var _datediff=DATEDIFF(MAX('Table'[RTA Current]),TODAY(),DAY)
return
IF(
    MAX('Table'[RTA Actual])<>BLANK(),"gray",
    IF(
        MAX('Table'[RTA Actual])=BLANK()&&_datediff<30,"yellow",
        IF(
         MAX('Table'[RTA Actual])=BLANK()&&MAX('Table'[RTA Current])<TODAY(),"red"  
)))

2. [[RTA Current] – Conditional formatting – Background color.

vyangliumsft_0-1705559789865.png

vyangliumsft_1-1705559789867.png

3. Result:

vyangliumsft_2-1705559820437.png

Best Regards,

Liu Yang

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

Great work!

vanessafvg
Super User
Super User

you could do it in a switch statement, and do some precalculations with the dates in a variable potentially to work out the time differences

https://learn.microsoft.com/en-us/dax/switch-function-dax

https://learn.microsoft.com/en-us/dax/datediff-function-dax

 

are you able to share your data in text format?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thanks for taking a look.  I'll read up on these options.  Here is a data excerpt:

 

ProjectRTARTA Actual
B591 breakroom HVAC repairs12/01/202201/18/2023
DDRT Add B811 to the DDRT FIS Contract01/22/2024 
DDRT B499A and B499B Fire Pump Repairs10/27/202205/15/2023
DDRT B581 Restroom Partition Renovation12/14/202212/14/2022
DDRT Renovation Building 552 Zone One Restrooms03/31/202203/30/2022
DDRT Replace Carpet in B50001/16/2024 
DDWG Bldg. 368 Overhang Bay E South West06/30/2023 
DDRT B499 East Dock Canopy Replacement1/22/2024 
DDWG Bldg. 660 Damaged Fire Riser Repair10/19/202210/19/2022
DDRT Inst Big Fans in B499 Z202/12/2024 
DDNV Replace Dry Fire System Compressors03/15/2024 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.