在 SSRS 中使用 IIF
Using IIF in SSRS
我正在尝试计算每个组的百分比值(逻辑为 'Group A Calls / Total Calls')。
问题是对于某些组我需要使用 (MAX(Fields!OverallCalls.Value) 而对于其他组我需要使用 (MAX(Fields!TotalCalls.Value)。出于这个原因,我在最底部添加了一个额外的 IIF 语句,但是,由于某种原因,我收到一条错误消息:'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)
)
存在缺少括号的错误。
试试下面的代码
=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)
)
)
我正在尝试计算每个组的百分比值(逻辑为 'Group A Calls / Total Calls')。
问题是对于某些组我需要使用 (MAX(Fields!OverallCalls.Value) 而对于其他组我需要使用 (MAX(Fields!TotalCalls.Value)。出于这个原因,我在最底部添加了一个额外的 IIF 语句,但是,由于某种原因,我收到一条错误消息:'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)
)
存在缺少括号的错误。
试试下面的代码
=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)
)
)