[英]SSRS Count or Sum expression
I cannot work out why these Total expressions don't work... 我无法弄清楚为什么这些Total表达式不起作用...
I am trying to add any cells that have a date later than today, with any cells that have "Not Reqd", and then divide that by the number of rows, to get a percentage. 我正在尝试将日期晚于今天的所有单元格与具有“ Not Reqd”的任何单元格相加,然后将其除以行数,以获得百分比。
All I'm getting is #Error
. 我得到的只是#Error
。
These are the expressions I've tried: 这些是我尝试过的表达式:
=SUM(IIf(Fields!Jetter_Trng.Value >Today OR
Fields!Jetter_Trng.Value = "Not Reqd",1,0)))/(Count(Fields!Jetter_Trng.Value)
and 和
=Count(IIf(Fields!Jetter_Trng.Value >Today OR
Fields!Jetter_Trng.Value = "Not Reqd",1,Nothing)))/(Count(Fields!Jetter_Trng.Value)
The "Not Reqd" string has come from an expression that changes a date (01/01/1950) to "Not Reqd". 字符串“ Not Reqd”来自将日期(01/01/1950)更改为“ Not Reqd”的表达式。 Maybe this is messing things up: 也许这搞砸了:
=iif(Fields!Jetter_Trng.Value = "01/01/1950", "Not Reqd", Fields!Jetter_Trng.Value)
The current working expression (not looking for "Not Reqd") is: 当前的工作表达式(不查找“ Not Reqd”)为:
=COUNT(IIF(Fields!Jetter_Trng.Value>Today,1,Nothing)))/(Count(Fields!Name.Value))
I'm a bit lost... 我有点迷路了...
A couple of notes on your expression as it stands at present 目前关于您的表情的一些注意事项
Jetter_Trng appears to be a string representing either a date or “Not Reqd”. Jetter_Trng似乎是代表日期或“ Not Reqd”的字符串。 You can't compare strings to dates without casting them to a date type first using CDATE() 如果不先使用CDATE()将字符串转换为日期类型,就无法将其与日期进行比较
The number of braces ( (
and )
) do not match 大括号( (
和)
)的数量不匹配
The root of your problem though is that you are using Jetter_Trng to return either a Date, or the value “Not Reqd”. 但是,问题的根源在于您正在使用Jetter_Trng返回Date或值“ Not Reqd”。
When SSRS attempts to evaluate an expression it does it all at the same time. 当SSRS尝试对表达式求值时,它将同时执行所有操作。 It doesn't follow a path to find the answer, and ignore other paths. 它不会遵循寻找答案的路径,而忽略其他路径。 Therefore, when you are attempting to compare 因此,当您尝试比较时
Fields!Jetter_Trng.Value >Today
This is comparing a string to a date, and throwing the error, as this mean nothing 这是将字符串与日期进行比较,并引发错误,因为这没有任何意义
"Not Reqd" > Today
You won't be able to do all that you want to using only one Field of type string. 您将无法仅使用一个字符串类型的字段来完成所有您想做的事情。
Your options are to 您的选择是
Using the second option here you could then use the following expression to create the desired calculation 在这里使用第二个选项,然后可以使用以下表达式创建所需的计算
=sum(iif(CDate(Fields!Jetter_Trng.Value) > Today, 1, 0)) /
Count(Fields!Jetter_Trng.Value)
Which would evaluate this dataset as follows 哪个将评估此数据集如下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.