【问题标题】:How to multiply only not null values in rdlc report expression如何在 rdlc 报告表达式中仅乘以非空值
【发布时间】:2014-04-24 22:58:51
【问题描述】:

如果 RDLC 报告表达式中不为空,如何将两个值相乘

我在用这个

=SUM(Fields!Quantity.Value*Fields!ExclusivePrice.Value)

更改为这个,但如果值为空,仍然会出错

=Sum((IIf(Fields!Quantity.Value 什么都没有, 0,Fields!Quantity.Value))*(IIf(Fields!ExclusivePrice.Value 什么都没有, 0,Fields!ExclusivePrice.Value)))

提前感谢您的帮助。

【问题讨论】:

    标签: rdlc


    【解决方案1】:

    在聚合之前,您必须将所有可能的值转换为相同的类型(CDec 表示 Decimal,CDbl 表示 Double 等)。

    例如,您可以像这样修改您的表达式:

    =Sum(IIf(Fields!Quantity.Value Is Nothing, CDec(0), CDbl(Fields!Quantity.Value)) * IIf(Fields!ExclusivePrice.Value Is Nothing, CDbl(0), CDec(Fields!ExclusivePrice.Value)))
    

    这是“压缩”版本:

    =Sum(IIf(Not IsNothing(Fields!Quantity.Value * Fields!ExclusivePrice.Value), CDbl(Fields!Quantity.Value * Fields!ExclusivePrice.Value), CDbl(0)))
    

    【讨论】:

      猜你喜欢
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 1970-01-01
      • 2016-01-22
      • 1970-01-01
      相关资源
      最近更新 更多