Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Conditional formatting using dax

I want Grey backgroung color where the matrix values are blank.  For that I wrote following measure but I am not getting desired output.   format= SWITCH(True(),SELECTEDVALUE('Employee Data'[Date...
  • Samarth_18's avatar
    Samarth_18
    4 years ago

    Anonymous Actually matrix visual not consider blank value for conditional formating when we use Format by as field value . So we need to do one work around.

    1. Update your Actual date column code with below code:-

    Actual Hours =
    VAR result =
        IF ( WEEKDAY ( 'Employee Data'[Date], 2 ) <= 5, 'Employee Data'[Hours Worked] )
    RETURN
        IF ( result = BLANK (), 0, result )

    2. Update your conditional formatting code with below code:-

    Conditional Formatting = 
    IF(
        SELECTEDVALUE('Employee Data'[Date])=TODAY(),
        "#E7F508",
        IF(
            SELECTEDVALUE('Employee Data'[Actual Hours])<4.5 && SELECTEDVALUE('Employee Data'[Actual Hours])>=4,
            "#08BCF5",
            IF(
                SELECTEDVALUE('Employee Data'[Actual Hours]) = 0,
            "#859CA4"
            )
        )
    )

    You will see below output:-