Forum Discussion

sy898661's avatar
sy898661
Helper V
7 years ago
Solved

Help with DAX changing colors

Hi!

 

I am trying to change the color of cells in a Table visual based off of some criteria, and althought I have not learned DAX, I have attempted to write a measure to help with this. Can someone please help me write this in correct syntax? (In case this doesnt make any sense, this is what I am trying to say):

 

If the Planned Date has passed, and the Actual Date is blank, change color of Actual Date cell RED

 

 

Actual Date Color Change =

     IF ( 'Date'[Planned Date] < TODAY,
          SWITCH(TRUE()
               'Date'[Actual Date] ISBLANK, "#FF0000",
          )
          "",
     )

 

     thank you! i know the code is probably really bad so please don't judge too hard!

  • sy898661 try following

     

    Actual Date Color Change =
    IF  (
           'Date'[Planned Date] < TODAY &&  
           'Date'[Actual Date] == BLANK(),  "#FF0000" 
    )
  • If you add a calculated column to your data table:

     

    the_color = IF(AND( MyData[PlannedDate] < TODAY() , ISBLANK(MyData[ActualDate]) ) , "#112233" , "#00AA00")

     

    You can then use the conditional formatting option in the table visualization for the Actual Date column to set its background colour to the value of the "the_colour" calculated column.

     

    Hope this helps.

2 Replies

  • sy898661 try following

     

    Actual Date Color Change =
    IF  (
           'Date'[Planned Date] < TODAY &&  
           'Date'[Actual Date] == BLANK(),  "#FF0000" 
    )
  • BeeBeeJay's avatar
    BeeBeeJay
    Frequent Visitor

    If you add a calculated column to your data table:

     

    the_color = IF(AND( MyData[PlannedDate] < TODAY() , ISBLANK(MyData[ActualDate]) ) , "#112233" , "#00AA00")

     

    You can then use the conditional formatting option in the table visualization for the Actual Date column to set its background colour to the value of the "the_colour" calculated column.

     

    Hope this helps.