SSRS在计算场上的聚合

问题描述:

我正在尝试对SSRS中的计算字段执行聚合,并收到以下错误:

I am trying to perform an aggregation on a calculated Field in SSRS and am getting the following error:


[rsAggregateReportItemInBody]值textrun'Textbox43.Paragraphs [0] .TextRuns [0]'的表达式在报表项上使用聚合函数。聚合函数只能用于页面页眉和页脚中包含的报表项

[rsAggregateReportItemInBody] The Value expression for the textrun 'Textbox43.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers

这是我尝试使用的公式:

This is the formula I tried to use:

=Sum(ReportItems!PlanPurchPrice.Value, "Select_UCPUtilization")

在这种情况下,PlanPurcPrice也是一个表达式:

In this Case PlanPurcPrice is also an Expression:

=First(Fields!PawPlanPurchPrice.Value, "Select_UCPUtilization")

对此的任何建议将不胜感激。

Any suggestions on this would be greatly appreciated.

SSRS 2008不支持您要查找的功能,除非报告项位于页眉或页脚中(如错误信息)。相反,我会提出两个替代解决方案:

SSRS 2008 does not support the functionality you are looking for unless the report item is located in the header or footer (as is stated in the error message). I would, instead, propose two alternate solutions:

第一个选项

放置查询中的计算(如果可能),此时您可以引用该字段,然后合计将根据需要运行。

Place the calculation in your query (if possible) at which point you can then reference the field and the aggregate will work as desired.

第二个选择

从本质上讲,您想创建要在报表中直接返回到Select_UCPUtilization范围的报表中返回的聚合,然后在其他位置引用聚合值。请按照下列步骤操作:

You essentially want to create the aggregate you're looking to return elsewhere in the report where it is directly connected to the Select_UCPUtilization scope, then reference the aggregated value elsewhere. Follow these steps:


  1. 在与报表项目PlanPurchPrice相同的范围内,计算PlanPurchPrice的总和。将包含总计的文本框命名为有意义的名称(例如Sum_PlanPurchPrice)。

  2. 直接引用该文本框,无论您之前尝试使用ReportItems总和的位置(即 = ReportItems!Sum_PlanPurchPrice.Value

隐藏替代方法。将您创建的聚合放置在附加到Select_UCPUtilization范围的其他列或行中。将文本变成白色,关闭增长和缩小,并使行很小(一个像素或两个高)。

Hide the workaround. Place the aggregate you created in an additional column or row attached to the Select_UCPUtilization scope. Turn the text white, turn off growth and shrinkage, and make the row very tiny (a pixel or two high).

使用第二个选项,报告项确实存在(并且可见,这很重要),并且

Using the second option, the report item does exist (and is visible, which is important) on the report and contains the sum you are looking to return elsewhere.

希望这会有所帮助。如果这没有任何意义,请通过评论回复,我们将尽力帮助您。

Hope this helps. if this doesn't make sense, please reply via comment and I'll help you to the best of my ability.