【问题标题】:SSRS Report Shows #Error When Converting Number to Currency将数字转换为货币时,SSRS 报告显示 #Error
【发布时间】:2021-11-04 18:35:14
【问题描述】:

我试图让报告显示用户在参数中输入的购买价格。如果用户没有输入任何内容,它将显示“未公开”,否则我希望它以货币形式显示购买价格。我尝试了以下方法:

=IIF(Parameters!PurchasePrice.Value = "", "Undisclosed", Cstr(Format(Parameters!PurchasePrice.Value, "C")))

=IIF(Parameters!PurchasePrice.Value = "", "Undisclosed", Format(Parameters!PurchasePrice.Value, "C"))

=IIF(Parameters!PurchasePrice.Value = "", "Undiscloded", FormatCurrency(Parameters!PurchasePrice.Value,0))

=IIF(Parameters!PurchasePrice.Value = "", "Undiscloded", FormatNumber(Parameters!PurchasePrice.Value,0))

我可以让“未公开”出现,但每次我输入一个数字时,它都会显示#Error

【问题讨论】:

  • 如果你使用它会发生什么? =IIF(Parameters!PurchasePrice.Value = "", "Undiscloded", Format(Parameters!PurchasePrice.Value,"'$'0.00;('$'0.00)"))

标签: reporting-services


【解决方案1】:

您可以尝试以下解决方案:

 =IIF(IsNumeric(Parameters!PurchasePrice.Value), Format(Val(Parameters!PurchasePrice.Value), "C"), "Undisclosed")

【讨论】:

    【解决方案2】:

    我会稍微不同地处理这个问题。这将避免 SSRS 尝试将非数字格式化为货币。 IIF 将评估真假结果,即使每个实例只有一个结果为真。

    我会将显示购买价格的文本框设置如下...

    Value 表达式设置为

    =VAL(Parameters!PurchasePrice.Value)
    

    如果参数值保留为空白/空字符串,这将返回零

    然后将文本框的Format属性设置为

    $#.00;-$#.00;Undisclosed
    

    假设您希望 $ 作为货币符号。此格式字符串会将正数和负数的数字格式化为两位小数,并在 $ 符号前面添加前缀,但对于零值,它将显示“未公开”的工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多