16

我正在使用以下表达式来计算百分比:

=Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name")

Days.Value 显示为 0 但是在我的一些结果中,而不是在我的百分比列中读取 0%,它实际上是在读取 NaN(不是数字)。

有谁知道我需要的确切表达式 forumla 以及我应该将它粘贴到我当前表达式中的哪个位置以说“NaN 显示的位置,改为输入 '0'?”

(见图)在此处输入图像描述

4

7 回答 7

20

我对上述答案没有运气。这对我有用:

=IIF(Single.IsNAN(Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name")), 0, Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"))
于 2012-12-11T15:15:00.770 回答
16

怎么样

=IIF(Fields!Days.Value > 0,Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"),0)
于 2012-01-13T09:23:54.270 回答
8

I used this for similar case,

=REPLACE(Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"),"NaN","0")

于 2014-11-12T05:16:39.637 回答
5

这是另一种选择。它应该解决问题,并摆脱Infinite响应:

=val(replace(Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"),"NaN","0"))
于 2017-07-12T10:36:53.533 回答
3

尝试

=IIf(Fields!Days.Value Is Nothing Or Sum(Fields!Days.Value, "Date_month_name") Is Nothing, 0, Fields!Days.Value / Sum(Fields!Days.Value, "Date_month_name"))
于 2012-01-13T03:31:27.190 回答
3

我认为这是最简单和最好的,

=Switch(
Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name") = "NaN",Nothing,
Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name") = "Infinity",Nothing,
Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name") = "-Infinity",Nothing
)

你也可以放一个 0 而不是什么都没有。

于 2014-05-27T11:43:16.150 回答
0

我有一个类似的问题,发现以下最容易做到。

=Iif(
Fields!Days.Value.Value <> 0 AND Sum(Fields!Days.Value, "Date_month_name") <> 0
, Fields!Days.Value.Value/Sum(Fields!Days.Value, "Date_month_name")
, 0
)

可能不是最好的解决方案,但有效。

于 2017-09-04T15:14:09.497 回答