How to use multiple conditions (With AND) in IIF expressions in ssrs How to use multiple conditions (With AND) in IIF expressions in ssrs sql-server sql-server

How to use multiple conditions (With AND) in IIF expressions in ssrs


Could you try this out?

=IIF((Fields!OpeningStock.Value=0) AND (Fields!GrossDispatched.Value=0) AND (Fields!TransferOutToMW.Value=0) AND (Fields!TransferOutToDW.Value=0) AND (Fields!TransferOutToOW.Value=0) AND (Fields!NetDispatched.Value=0) AND (Fields!QtySold.Value=0) AND (Fields!StockAdjustment.Value=0) AND (Fields!ClosingStock.Value=0),True,False)

Note: Setting Hidden to False will make the row visible


You don't need an IIF() at all here. The comparisons return true or false anyway.

Also, since this row visibility is on a group row, make sure you use the same aggregate function on the fields as you use in the fields in the row. So if your group row shows sums, then you'd put this in the Hidden property.

=Sum(Fields!OpeningStock.Value) = 0 AndSum(Fields!GrossDispatched.Value) = 0 And Sum(Fields!TransferOutToMW.Value) = 0 AndSum(Fields!TransferOutToDW.Value) = 0 AndSum(Fields!TransferOutToOW.Value) = 0 AndSum(Fields!NetDispatched.Value) = 0 AndSum(Fields!QtySold.Value) = 0 AndSum(Fields!StockAdjustment.Value) = 0 AndSum(Fields!ClosingStock.Value) = 0

But with the above version, if one record has value 1 and one has value -1 and all others are zero then sum is also zero and the row could be hidden. If that's not what you want you could write a more complex expression:

=Sum(    IIF(        Fields!OpeningStock.Value=0 AND        Fields!GrossDispatched.Value=0 AND        Fields!TransferOutToMW.Value=0 AND        Fields!TransferOutToDW.Value=0 AND         Fields!TransferOutToOW.Value=0 AND        Fields!NetDispatched.Value=0 AND        Fields!QtySold.Value=0 AND        Fields!StockAdjustment.Value=0 AND        Fields!ClosingStock.Value=0,        0,        1    )) = 0

This is essentially a fancy way of counting the number of rows in which any field is not zero. If every field is zero for every row in the group then the expression returns true and the row is hidden.


Here is an example that should give you some idea..

=IIF(First(Fields!Gender.Value,"vw_BrgyClearanceNew")="Female" and (First(Fields!CivilStatus.Value,"vw_BrgyClearanceNew")="Married"),false,true)

I think you have to identify the datasource name or the table name where your data is coming from.