0
votes

I'm trying to calculate % value for each group (logic being 'Group A Calls / Total Calls').

The problem is that for some groups I need to use (MAX(Fields!OverallCalls.Value) whereas for other ones I need to use (MAX(Fields!TotalCalls.Value). For this reason, I've added an additional IIF statement at the very bottom, however, for some reason I get an error saying: 'Too many arguments to Public Functions IsNothing(Expression As Object) As Boolean'.

=FORMATPERCENT(
       Sum(
IIF(Fields!Group.Value = "Dissatisfactions Total",
       Fields!TotalDissatisfactions.Value,
IIF(Fields!Group.Value = "RID Total",
       Fields!TotalRidDissatisfactions.Value,
       IIF(
              Fields!Group.Value = "CRT" OR
              Fields!Group.Value = "Escalations"
              ,Fields!ComplaintID.Value
              ,IIF(
                           Fields!Group.Value = "Calls"
                           ,Fields!Calls.Value
                           ,0
                     )
       )
       )
       )  
       ) / IIF(IsNothing(MAX(Fields!OverallCalls.Value), (MAX(Fields!TotalCalls.Value), (MAX(Fields!OverallCalls.Value)
       )
1

1 Answers

1
votes

There are errors with missing parenthesis.

Try the following code

=FORMATPERCENT(
Sum(
    IIF(Fields!Group.Value = "Dissatisfactions Total",
        Fields!TotalDissatisfactions.Value,
        IIF(Fields!Group.Value = "RID Total",
            Fields!TotalRidDissatisfactions.Value,
            IIF(
            Fields!Group.Value = "CRT" OR Fields!Group.Value = "Escalations",
                Fields!ComplaintID.Value,
                IIF(
                    Fields!Group.Value = "Calls",
                    Fields!Calls.Value,
                    0
                    )
                )
            )
        )  
   ) 
   / 
   IIF(IsNothing(MAX(Fields!OverallCalls.Value)),  
        MAX(Fields!TotalCalls.Value),  
        MAX(Fields!OverallCalls.Value) 
    )
   )

Also for better readability when you have many nested Iif statements I would advice using switch like the following code

=FORMATPERCENT(
Sum(
    Switch (
        Fields!Group.Value = "Dissatisfactions Total", Fields!TotalDissatisfactions.Value,
        Fields!Group.Value = "RID Total", Fields!TotalRidDissatisfactions.Value,
        Fields!Group.Value = "CRT" OR Fields!Group.Value = "Escalations", Fields!ComplaintID.Value,
        Fields!Group.Value = "Calls", Fields!Calls.Value,
        True, 0
        )

   / 
   IIF(IsNothing(MAX(Fields!OverallCalls.Value)),  
        MAX(Fields!TotalCalls.Value),  
        MAX(Fields!OverallCalls.Value) 
    )
   )