Forum Discussion

beatrizcorrea's avatar
beatrizcorrea
New Member
2 years ago
Solved

DAX Conditional Formatting - Multiple Conditions traffic lights - PBI

I need to do conditional formatting where I will use semaphores. If the service level is greater than the target value, the traffic light will turn green, If the service level is less than the target value and greater than 50%, the traffic light will turn yellow, and if the service level is less than 50%, the traffic light will turn red. Bu I can't make it work with these conditions:

FarolKPI =
var cor = IF({_FactService_Measures[ServiceLevel]} >= SELECTEDVALUE(DimService[Target]), "Green",
IF({_FactService_Measures[ServiceLevel]} < SELECTEDVALUE(DimService[Target]) && {_FactService_Measures[ServiceLevel]} <= 0.5, "Yellow", "Red"
))

var icone = "data&colon;image/svg+xml;utf8," &
"<svg
xmlns='http://www.w3.org/2000/svg' viewBox='0
0 130 130'>

<circle cx='60' cy='60' r='55'
fill='" & cor & "' />
</svg>"

RETURN icone


Can someone help me, please?
Thank you!



  • I found the solution, it is:

    FarolKPI =
    VAR target = SELECTEDVALUE(DimService[Target])
    VAR cor =
        IF({_FactService_Measures[ServiceLevel]} >= target, "Green",
            IF({_FactService_Measures[ServiceLevel]} < target && {_FactService_Measures[ServiceLevel]} <= 0.5, "Red", "Yellow"))
    VAR icone = "data&colon;image/svg+xml;utf8," &
    "<svg
    xmlns='http://www.w3.org/2000/svg' viewBox='0 0 130 130'>

    <circle cx='60' cy='60' r='55'
    fill='" & cor & "' />
    </svg>"

    RETURN icone

2 Replies

  • I found the solution, it is:

    FarolKPI =
    VAR target = SELECTEDVALUE(DimService[Target])
    VAR cor =
        IF({_FactService_Measures[ServiceLevel]} >= target, "Green",
            IF({_FactService_Measures[ServiceLevel]} < target && {_FactService_Measures[ServiceLevel]} <= 0.5, "Red", "Yellow"))
    VAR icone = "data&colon;image/svg+xml;utf8," &
    "<svg
    xmlns='http://www.w3.org/2000/svg' viewBox='0 0 130 130'>

    <circle cx='60' cy='60' r='55'
    fill='" & cor & "' />
    </svg>"

    RETURN icone
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi beatrizcorrea ,

      I am glad you have solved the problem, please consider Accept it as the solution to help the other members find it more quickly.

       

      Best Regards,

      Wisdom Wu