Forum Discussion

cham's avatar
cham
Post Patron
6 years ago
Solved

VAR formula with multiple return values

Hi,   I have data set with week1 , week2, week3, week4 and with the staus of "Completed", "inprogress" and "Failed".   I used below formul to do the conditional formatting in my data set since it...
  • v-gizhi-msft's avatar
    6 years ago

    Hi,

     

    According to your description, I create a simple sample to test:

    The issue is because that you apply one measure to all columns.

    So for each row, it will show the same color regardless of the value, like this:

    color = 
    var w1 = SELECTEDVALUE('Table'[Week 1])
    var w2 = SELECTEDVALUE('Table'[Week 2])
    var w3 = SELECTEDVALUE('Table'[Week 3])
    return
    SWITCH(true,w1="Completed","Green",w1="In Progress","Blue",w1="Failed","Red",
                w2="Completed","Green",w2="In Progress","Blue",w2="Failed","Red",
                w3="Completed","Green",w3="In Progress","Blue",w3="Failed","Red"
    )

    Please try to create measures for each week:

    Measure 1 = SWITCH(SELECTEDVALUE('Table'[Week 1]),"Completed","Green","In Progress","Blue","Failed","Red")
    Measure 2 = SWITCH(SELECTEDVALUE('Table'[Week 2]),"Completed","Green","In Progress","Blue","Failed","Red")
    Measure 3 = SWITCH(SELECTEDVALUE('Table'[Week 3]),"Completed","Green","In Progress","Blue","Failed","Red")

    Then apply these to each week's font color:

    And the result shows:

    Hope this helps.

     

    Best Regards,

    Giotto Zhi