Search code examples
reporting-servicessql-server-2012expression

Using multiple dataset for =iif(isNothing(First(Fields!field.Value


I have the below expression but want to add additional datasets into the existing expression for validation.

Existing expression:

=iif(isNothing(First(Fields!ordnum.Value, "FirstDataset")) = True, "No","Yes")

I would like to do something like the below in which if any data is present within any of the datasets, the result returns Yes, otherwise, No

=iif(isNothing(First(Fields!ordnum.Value, "FirstDataset"),(Fields!ordnum.Value, "SecondDataset"),(Fields!ordnum.Value, "ThirdDataset") ) = True, "No","Yes")

Something else I tried is but get the following error: The Value expression for the textrun ‘ordnum_1.Paragraphs[0].TextRuns[0]’ contains an error: [BC30516] Overload resolution failed because no accessible 'IIf' accepts this number of arguments.

=iif(isNothing(First(Fields!ordnum.Value, "FirstDataset")) = True, "No","Yes", iif(isNothing(First(Fields!ordnum.Value, "SecondDataset")) = True, "No","Yes"), iif(isNothing(First(Fields!ordnum.Value, "ThirdDataset")) = True, "No","Yes"))

Solution

  • You can use an OR in the IIF to check for any one of multiple conditions.

    =IIF(ISNOTHING(First(Fields!ordnum.Value, "FirstDataset")) OR
        ISNOTHING(First(Fields!ordnum.Value, "SecondDataset")) OR 
        ISNOTHING(First(Fields!ordnum.Value, "ThirdDataset")), "No","Yes")