Search code examples
reporting-servicesssrs-2008

Fill Color based on Cell Value


I have the following code (a nested IIF/Lookup) for determining the color of a particular cell. It works for the FIRST value (APPROVED) but every other value results in no fill color. I want to note too that the values are populated from a drop down list so there is no mistyped or issues with case. The Lookup values are correct too. I've double checked that as well.

=IIF((Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "APPROVED"),
    IIF((Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "PENDING"),
        IIF((Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "DEAD"),
            IIF((Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "APPROVED/ORDER PLACED"),
 "Aqua",
    "Tomato"),
        "Yellow"),
            "Lime"),
Nothing)

Solution

  • Nested IIF's are awful to read, I always use SWITCH(), it's simpler to read and debug.

    I can't test this right now but it should be OK

    =SWITCH(
        Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "APPROVED", "Lime", 
        Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "PENDING", "Yellow", 
        Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "DEAD", "Tomato", 
        Lookup(Fields!ID.Value, Fields!ParentLink139.Value, Fields!TTStatus.Value, "TrialTracker") = "APPROVED/ORDER PLACED", "Aqua", 
        True, Nothing
    )
    

    The final True just acts like an ELSE.