我正在尝试计算每个组的百分比值(逻辑为“ A组通话次数/总通话次数”)。
问题是,对于某些组,我需要使用(MAX(Fields!OverallCalls.Value),而对于其他组,我需要使用(MAX(Fields!TotalCalls.Value)。因此,我添加了一个附加组但是,由于某种原因,IIF语句位于最底部,我收到一条错误消息:“公共函数IsNothing(作为对象的表达式)为布尔值的参数过多”。
=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)
)
缺少括号的错误。
尝试以下代码
=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)
)
)
同样,当您有许多嵌套的Iif语句时,为了提高可读性,我建议使用类似以下代码的switch开关>>
=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)
)
)