Reporting Services - 如果等于 A,则计算列值 [英] Reporting Services - Count Column Values if equals A

查看:42
本文介绍了Reporting Services - 如果等于 A,则计算列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为dsAllStuTargetData"的数据集 - 我正在尝试计算目标"列中出现的A"值的数量.

I have a dataset called 'dsAllStuTargetData' - i'm trying to count the number of the 'A' values that appear in the column 'Target'.

我使用带有表达式的文本框执行此操作,我可以使用以下方法计算值的总数:

I'm doing this using a textbox with an expression, I can count the total number of values using the following:

=Count(Fields!Target.Value, "dsAllStuTargetData")

但是,当我尝试计算值等于A"的位置时,它不起作用.

However when I try to count where the value equals 'A' it doesn't work.

=Count(IIF(Fields!Target.Value, "dsAllStuTargetData")="A",1,0)

推荐答案

对于这种情况,您需要一个 Sum,而不是 Count,例如:

For this case you need a Sum, not a Count, i.e. something like:

=Sum(IIf(Fields!Target.Value = "A", 1, 0), "dsAllStuTargetData")

Count 只会计算行数;IIf 在那里不做任何事情 - 在某些情况下可能会影响 CountDistinct 之类的东西,但这在这里不起作用.

Count will just count the number of rows; the IIf doesn't do anything there - something like CountDistinct can be affected in certain cases but this will not work here.

然而,Sum 将取所有满足IIf 条件的行的总和,即DataSet 中所有1 值的总和,这就是您所追求的.

However, Sum will take the total of all rows which meet the IIf condition, i.e. the total of all 1 values in the DataSet, which is what you're after.

这篇关于Reporting Services - 如果等于 A,则计算列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆