计数严重错误
我正在尝试在 Visual Studio 2008 中创建 rdlc 报告,但在最后的总计方面遇到了一些麻烦。
我有一个名为“Reward”的字符串字段,显示 1、2、3 或 B。在报告末尾,我需要计算总记录数、“B”数和非“B”数” s。所以我倾向于在底部设置三个字段:
Total =COUNT(IIF(Fields!Reward.Value > "a",1,0))
Bs =COUNT(IIF(Fields!Reward.Value = "B",1,0))
Non-Bs =COUNT(IIF(Fields!Reward.Value <> "B",1,0))
但所有三个字段最终都等于相同的(总记录数)。我认为这看起来很奇怪,所以我尝试了根本没有出现在该列中的数据,例如
=COUNT(IIF(Fields!Reward.Value = "4",1,0))
我仍然得到相同的数字。有什么想法我做错了吗?
I'm trying to create a rdlc report in Visual Studio 2008 and I'm having a bit of trouble with the totals at the end.
I have a string field called "Reward" that displays either 1, 2, 3 or B. At the end of the report, I need to count up how many total records, how many "B"s and how many are not "B"s. So my inclination is to have three fields at the bottom as such:
Total =COUNT(IIF(Fields!Reward.Value > "a",1,0))
Bs =COUNT(IIF(Fields!Reward.Value = "B",1,0))
Non-Bs =COUNT(IIF(Fields!Reward.Value <> "B",1,0))
But all three end up equaling the same (the total record count). I thought that seemed weird so I tried data that doesn't appear in that column at all such as
=COUNT(IIF(Fields!Reward.Value = "4",1,0))
and I still get the same number. Any ideas what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您想要
SUM
而不是COUNT
?如果您从
IIF
返回值 0 或 1,则实际上只是计算返回的值的数量,无论其中的数值是什么。将 B 和非 B 更改为
SUM
,您将获得所需的结果。Perhaps you want
SUM
instead ofCOUNT
?If you're returning value 0 or 1 from your
IIF
, you're actually just counting how many values are being returned, no matter the numeric value within.Change the Bs and Non-Bs to
SUM
, and you'll get the results you're looking for.