如何在组级列上正确设置SUM AGGREGATE

时间:2018-09-19 00:36:11

标签: reporting-services ssrs-tablix

我有一个SSRS报告,我正在尝试对其中一列求和。

enter image description here

第一列是countdistinct(field1),效果很好。

第二列与第一列在同一组中。当第一列展开时,第二列是第一组的一部分。

我正在尝试在组总数中获取24的值。 如果我执行[SUM(CDEC(FIELD2.value))],则会导致72,因为从技术上讲,这12条记录会在所有6条记录中重复出现。

[SUM(MAX(FIELD2.value))]产生12,因为MAX()函数给出所有记录的最大值。

我如何在这里获得24?

谢谢

更新#1。 这是这些列的字段设置 enter image description here

enter image description here

有人提到在我的sum()中使用范围。如何确定我的范围是什么?谢谢!

1 个答案:

答案 0 :(得分:1)

您必须在tablix的sum表达式中添加范围,否则它将始终获取数据集数据。假设您有一个数据集( Dataset1 ),其中包含字段 SalesOrder SalesPrice 。如果现在按 SalesOrder GroupingBySalesOrder )在Tablix中进行分组,则可以为聚合函数添加不同的作用域:

=Sum(Fields!SalesPrice.Value) 'This takes the Default scope "Dataset1"
=Sum(Fields!SalesPrice.Value, "Dataset1") 'The same result like above
=Sum(Fields!SalesPrice.Value, "GroupingBySalesOrder") 'The scope is now your grouping. Different result like the other two