添加可能包含NULL的两个字段 - SSRS

时间:2017-12-07 20:47:51

标签: reporting-services expression ssrs-2012

我正在尝试在SSRS表达式中添加两个可能包含NULL值的字段。在包含NULL的记录上,我在报告界面上收到#Error。

我尝试使用以下内容处理NULL:

=SUM( IIF(IsNothing(Fields!TotalSale.Value),0,Fields!TotalSale.Value) + IIF(IsNothing(Fields!TotalVoidedSale.Value),0,Fields!TotalVoidedSale.Value) )

=SUM( IIF(IsNothing(Fields!TotalSale.Value),Nothing,Fields!TotalSale.Value) + IIF(IsNothing(Fields!TotalVoidedSale.Value),Nothing,Fields!TotalVoidedSale.Value) )

并且都不起作用。有人能指出我在这里做错了吗?

1 个答案:

答案 0 :(得分:1)

如果这是针对详细级别的数据,那么您可能只想删除SUM并继续使用:

=IIF(IsNothing(Fields!TotalSale.Value),0,Fields!TotalSale.Value) + IIF(IsNothing(Fields!TotalVoidedSale.Value),0,Fields!TotalVoidedSale.Value)

如果您需要将此表达式作为聚合,那么您需要两个将两个单独的总和相加:

=SUM(IIF(IsNothing(Fields!TotalSale.Value),0,Fields!TotalSale.Value)) + SUM(IIF(IsNothing(Fields!TotalVoidedSale.Value),0,Fields!TotalVoidedSale.Value))