Search code examples
reporting-servicesexpressionsql-server-2014iif

How do I use the Lookup expression and the IIF expression in SSRS?


I have researched and not been able to find the answer to my question. My goal is to use the Lookup function in SSRS, which is currently performing as intended. However, I have null values that are not present which I would represented as '0'. It seems like I should be able to use the Lookup expression along with a IIF function. However, I cannot find an example of this. Any ideas how I can accomplish this? My Lookup expression is below.

=LookUp(Fields!SKU.Value,
Fields!ItemCode.Value, 
Fields!Store.Value, "DataSet3")

Solution

  • I'd use IsNothing function to check if the value is Null and wrap it in a IIF expression. Here is the Microsoft reference for different expressions.

    =IIF
    (
      IsNothing(LookUp(Fields!SKU.Value, Fields!ItemCode.Value, Fields!Store.Value, "DataSet3"))
    , 0
    , LookUp(Fields!SKU.Value, Fields!ItemCode.Value, Fields!Store.Value, "DataSet3")
    )