SSRS Formula or expression to change NaN to 0

2019-04-21 19:52发布

I am using the following expression to work out a percentage:

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

Days.Value is showing as 0 however in a few of my results instead of reading 0% in my percentage column it is actually reading NaN (Not a Number).

Does anyone know the exact expression forumla i need and where I should paste it in my current expression to say "Where NaN is showing, put a '0' instead?"

(See image)enter image description here

7条回答
干净又极端
2楼-- · 2019-04-21 20:25

How about

=IIF(Fields!Days.Value > 0,Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"),0)
查看更多
别忘想泡老子
3楼-- · 2019-04-21 20:26

Try

=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"))
查看更多
淡お忘
4楼-- · 2019-04-21 20:27

Here's another option. It should solve the problem, and also get rid of Infinite responses:

=val(replace(Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"),"NaN","0"))
查看更多
女痞
5楼-- · 2019-04-21 20:39

I didn't have luck with the above answers. Here's what worked for me:

=IIF(Single.IsNAN(Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name")), 0, Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"))
查看更多
Deceive 欺骗
6楼-- · 2019-04-21 20:42

I used this for similar case,

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

查看更多
欢心
7楼-- · 2019-04-21 20:45

I had a similar issue to this and found that the following was easiest to do.

=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
)

Probably not the best solution, but works.

查看更多
登录 后发表回答