Reputation: 13
Compilation error for nested iif
=IIf(Fields!no_of_employees.Value = max(Fields!no_of_employees.Value,"DataSet1"),"Lime","Gold",
IIf(Fields!no_of_employees.Value = min(Fields!no_of_employees.Value,"DataSet1"),"Red","Gold"
))
I was trying to implement nested iif.
Upvotes: 0
Views: 96
Reputation: 21683
If you look at your statement, you have passed 4 arguments to the first IIF
To write a normal IIF
you would do something like
=IIF(
ConditionA=True,
TrueResult,
FalseResult
)
When writing a nested IIF
you would do something like this
=IIF(
ConditionA=True,
TrueResult,
IIF(
ConditionB=True,
TrueResult,
FalseResult
)
)
To fix your code, remove the first instance of "Gold",
.
I prefer to use SWITCH()
instead of nested IIF
s as I think it's easier to read.
If you want to use SWITCH()
then you can rewrite your expression as follows.
=SWITCH(
Fields!no_of_employees.Value = max(Fields!no_of_employees.Value,"DataSet1"), "Lime",
Fields!no_of_employees.Value = min(Fields!no_of_employees.Value,"DataSet1"), "Red",
True, "Gold"
)
The final True
just acts like an ELSE. You can read more about SWITCH()
here .
Upvotes: 1