Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 在VisualStudio的子表中使用聚合函数_Sql Server_Visual Studio 2008_Reporting Services_Count_Aggregate Functions - Fatal编程技术网

Sql server 在VisualStudio的子表中使用聚合函数

Sql server 在VisualStudio的子表中使用聚合函数,sql-server,visual-studio-2008,reporting-services,count,aggregate-functions,Sql Server,Visual Studio 2008,Reporting Services,Count,Aggregate Functions,我正试图在VisualStudio2008中使用SSRS在我的报告中创建一个子表。我遇到的问题是正确使用函数并通过主报表引用报表项。在我的报告中,我有一个表达式,当从主查询返回特定值时,它会对其进行颜色编码。在我的子表中,我想计算特定值的每个实例,例如: Main Report Supervisor Employee Ranking Supervisor 1 Employee 1 Meets (Labeled Orange) Supervisor

我正试图在VisualStudio2008中使用SSRS在我的报告中创建一个子表。我遇到的问题是正确使用函数并通过主报表引用报表项。在我的报告中,我有一个表达式,当从主查询返回特定值时,它会对其进行颜色编码。在我的子表中,我想计算特定值的每个实例,例如:

Main Report

Supervisor            Employee   Ranking 
Supervisor 1          Employee 1  Meets (Labeled Orange)
Supervisor 1          Employee 2  Outstanding (Labeled Yellow)
Supervisor 2          Employee 3  Meets
Supervisor 2          Employee 4  Meets

Subtable              Outstanding     Meets
Supervisor 1              1            1
Supervisor 2              0            2
我试过使用以下公式

=count(Reportitems!Ranking.Value, "Meets", 0)
=count(Reportitems!Ranking.Value, "Orange", 0)
=count(Reportitems!Ranking.Value = "Meets")
=count(Reportitems!Ranking.Value = "Orange")
我还将
=count
更改为
=countrows
=countdistinct


有人能帮忙吗?我对任何事情都持开放态度,我只希望报告和子表能够正确工作

一旦您获得了一个由主管分组的表(看起来是这样的),您就需要添加两个带有两个条件表达式的列:

杰出专栏:

会见专栏:

这些将统计每个返回的主管的未完成和会议的发生次数

这假设
排名
只是数据集中的一列-您提到了基于此的颜色编码,但我们只对基本值感兴趣,而不是颜色

评论后编辑

如果
排名
基于一个表达式,您可以简单地将其添加到上面的原始表达式中,例如:

=Sum(IIf(<MyExpression> = "Outstanding", 1, 0))
=总和(IIf(“未偿”,1,0))
这是一个有点笼统的答案,因为我不知道您的具体示例是什么,但您可以毫无疑问地在其他表达式中嵌套表达式


对于一个更优雅的解决方案,您应该考虑将<强>计算字段添加到您的DataSet中——这在数据集中定义了一次表达式,然后可以像报表本身中的普通字段那样使用它。通过这种方式,您可以在数据集中创建一个名为

Ranking
的计算字段,然后您可以使用原始答案中引用此新计算
Ranking
字段的表达式。

Meets和“Understand”的值来自一个表达式,而不是来自原始查询的数据集的一部分。有没有办法使用从表达式中提取返回数据的表达式?@user3216484,我在答案中添加了更多细节。当我将其放入表达式中时,会出现“聚合函数只能位于页眉和页脚中”的错误。我试图将该列添加到查询中,但是,由于我们不断地改变数字和排名,因为越来越多的钱来了,我无法让它工作=iif(fields!KPO.Value)为空,iif(fields!Score.Value>=ReportItems!K_Score.Value,“E”,iif(fields!Score.Value>=ReportItems!K_Score2.Value,“M”,“OP”),“OS”)是我用来计算值的表达式,但由于需要条件评分,我无法在查询中使用它。
=Sum(IIf(Fields!Ranking.Value = "Meets", 1, 0))
=Sum(IIf(<MyExpression> = "Outstanding", 1, 0))