计数严重错误

发布于 2024-09-12 04:08:04 字数 513 浏览 3 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦归所梦 2024-09-19 04:08:04

也许您想要 SUM 而不是 COUNT

如果您从 IIF 返回值 0 或 1,则实际上只是计算返回的值的数量,无论其中的数值是什么。

将 B 和非 B 更改为 SUM,您将获得所需的结果。

Perhaps you want SUM instead of COUNT?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文