KathH
KathH

Reputation: 39

Sum of a nested iif statement

I have the following nested iif statement that brings back an error "End of Statement expected." Can someone please help? I know its probably very straightforward but i have been looking at this for sometime. Thanks

=SUM(IIF(Fields!Grade.Value = "A*", 6, IIF(Fields!Grade.Value = "A", 5, IIF(Fields!Grade.Value = "B", 4, IIF(Fields!Grade.Value = "C" , 3, IIF(Fields!Grade.Value = "D" , 2 , IIF(Fields!Grade.Value = "E", 1, IIF(Fields!Grade.Value = "E/U", 0))))))) - IIF(Fields!Target_Grade.Value = "A*" , 6, IIF(Fields!Target_Grade.Value = "A", 5, IIF(Fields!Target_Grade.Value = "B", 4 , IIF(Fields!Target_Grade.Value = "C", 3, IIF(Fields!Target_Grade.Value = "D", 2, IIF(Fields!Target_Grade.Value = "E" , 1, IIF(Fields!Target_Grade.Value = "U", 0)))))))))

Upvotes: 0

Views: 439

Answers (2)

KathH
KathH

Reputation: 39

I needed an else 0 statement, added this to the code to give the below and all is good

=SUM(IIF(Fields!Grade.Value = "A*", 6, IIF(Fields!Grade.Value = "A", 5, IIF(Fields!Grade.Value = "B", 4, IIF(Fields!Grade.Value = "C" , 3, IIF(Fields!Grade.Value = "D" , 2 , IIF(Fields!Grade.Value = "E", 1, IIF(Fields!Grade.Value = "E/U", 0, 0))))))) - IIF(Fields!Target_Grade.Value = "A*" , 6, IIF(Fields!Target_Grade.Value = "A", 5, IIF(Fields!Target_Grade.Value = "B", 4 , IIF(Fields!Target_Grade.Value = "C", 3, IIF(Fields!Target_Grade.Value = "D", 2, IIF(Fields!Target_Grade.Value = "E" , 1, IIF(Fields!Target_Grade.Value = "U", 0, 0))))))))

Upvotes: 0

Rich
Rich

Reputation: 2279

I think you have one too many closing brackets- you could try removing the last bracket.

(I pasted your code into Notepad++ and put in a carriage return for each opening bracket and closing bracket. Notepad++ highlights the matching opening and closing brackets, and there was one left over))

Upvotes: -1

Related Questions