Patrick
Patrick

Reputation: 27

SSRS Report builder with multiple IIf expressions, how to read the code

I have an old report with a column that has an expression looking like this:

=IIf(Sum(Fields!projqty.Value)<>0, IIf(Max(Fields!projekttargettime.Value)=1, (Sum(Fields!projtime.Value+Fields!acwtime.Value)), (Sum(Fields!projqty.Value)*Fields!targettime.Value)), (Sum(Fields!projqty.Value)*Fields!targettime.Value))

I dont understand how to read the code and wonder if someone could explain it?

Upvotes: 0

Views: 613

Answers (1)

BishNaboB
BishNaboB

Reputation: 1070

This is called an inline if, or iif().

An inline if basically goes along the lines of: iif(<test condition>, <value for true>, <value for false>)

For your example, you also have nested iif() statements to work things out. It goes..

IIf(Sum(Fields!projqty.Value)<>0 - check to see if this sum(Fields!projqty.Value) is not equal to 0

IIf(Max(Fields!projekttargettime.Value)=1 - the first test was true (not equal to 0), so now we want to check if this max(Fields!projekttargettime.Value) is equal to 1

(Sum(Fields!projtime.Value+Fields!acwtime.Value)), - we got here because the sum(Fields!projqty.Value) is not equal to 0 and the max(Fields!projekttargettime.Value) is equal to 1

(Sum(Fields!projqty.Value)*Fields!targettime.Value)), - we got here because the sum(Fields!projqty.Value) is not equal to 0 and the max(Fields!projekttargettime.Value) does not equal 1

(Sum(Fields!projqty.Value)*Fields!targettime.Value)) - and finally, we got here because the original sum(Fields!projqty.Value) is equal to 0. We never check for max(Fields!projekttargettime.Value) as we don't reach that part of the iif()

See here for more information on expressions in SSRS.

Upvotes: 1

Related Questions