
Originally Posted by
hmartin
I should have posted this expression. I get a comma error when I try to run it.
TotalRateAllPositions: (IIf([CABIHours]>8,(500+([CABIHours]-8)*93.75),[CABIHours]*62.5),IIf([ProjectManagerHours]>8,(576+([ProjectManagerHours]-8)*95),[ProjectManagerHours]*72),IIf([AMSHours]>8,(576+([AMSHours]-8)*95),[AMSHours]*72))
From your first post, these three expressions have improper syntax:
Code:
CABIHours: IIf([work hours]![work code]=60,[hours])
ProjectManagerHours: IIf([work hours]![work code]=14,[hours])
AMSHours: IIf([work hours]![work code]=62,[hours])
The syntax is:
Code:
IIF(condition, TRUE clause, FALSE clause)
You are missing the FALSE clause. It is not optional.
Then when you use them in the TotalRateAllPositions expression, you are receiving an error. There are too many close parentheses and not enough commas.
You have a 9 level nested IIF() function. That is a lot. It might be better to write a UDF.
You can consolidate conditions... I would start out with the skeleton
Code:
IIF(condition, TRUE clause, FALSE clause)
add the conditions:
Code:
IIF([work code]=60 or [work code]=14 or[work code]=62, TRUE clause, FALSE clause)
then add the TRUE clause:
Code:
IIF([work code]=60 or [work code]=14 or[work code]=62, [hours], FALSE clause)
You are going to have another IIF() statement, so add that as the FALSE clause:
IIF([work code]=60 or [work code]=14 or[work code]=62, [hours], IIF(
condition, TRUE clause, FALSE clause))
Add another condition (in blue) for the 2nd IIF() function, add the TRUE clause, then add another IIF() as the FALSE clause. Continue building the expression until you a) are done or b) reach the max nesting limit.