[英]Getting YTD figure in SSRS report with filtered column group on year/month
I have a Reporting Services report which shows a bunch of KPI scores. 我有一个Reporting Services报告,其中显示了一堆KPI分数。 Each KPI has it's own Row on the report and for each row we show the SUM or AVG (depending on KPI type) score for last 3 years, and then a SUM, AVG or (ideally) total YTD figure per month in the current year: 每个KPI在报告中都有其自己的行,对于每一行,我们将显示最近3年的SUM或AVG(取决于KPI类型)得分,然后是当年每月每月的SUM,AVG或(理想情况下)总YTD值:
KPI 2009 2010 2011 Jan Feb Mar Apr May etc.
Bagels Eaten (Total) 100 90 70 10 20 9 13 14
Sandwiches (Cumm. YTD) 90 75 86 13 23 46 65 76
The problem I'm seeing is that the RunningValue function appears to be working across rows, instead of within the filtered column group and current row that makes up the Jan, Feb, Mar columns (monthly data, grouped by year and month, filtered on current year). 我看到的问题是RunningValue函数似乎跨行工作,而不是在构成Jan,Feb和Mar列的已过滤列组和当前行内(每月数据,按年和月分组,按今年)。 So the output is not as above, instead its a fairly random figure based on all the values in the rows (I'm sure it's not random it just looks like it is). 因此输出不是上面的输出,而是基于行中所有值的相当随机的数字(我确定它不是随机的,只是看起来像这样)。
The Column Group is called "MonthNum" and the Expression for the cell value decides which aggregation to apply based on an "AggregationType" value in the source data: 列组称为“ MonthNum”,单元格值的表达式根据源数据中的“ AggregationType”值确定要应用的聚合:
=Switch(Fields!AggregationType.Value="SUM", Sum(Fields!ScoreValue.Value),
Fields!AggregationType.Value="AVG", Avg(Fields!ScoreValue.Value),
Fields!AggregationType.Value="YTD",
RunningValue(Fields!ScoreValue.Value,Sum,"MonthNum"))
Any help much appreciated 任何帮助,不胜感激
Update: Here is an example few rows (scores per month, per kpi) of the data set being used (formatting is a bit tricky!). 更新:这是一个示例,显示正在使用的数据集的几行(每月分数,每个kpi)(格式有点棘手!)。 Items with aggragation type 'YTD' would have the cummulative YTD expression applied, everything else would be SUM for the current month: 集结类型为“ YTD”的项目将应用累计的YTD表达式,其他所有内容均为当月的SUM:
KpiID Title KPIOwner ScoreValue YearNum MonthNum ReportingGroupTitle ScoreType DisplayOrder DisplayPrecision UnitOfMeasure AggregationType
5 Donuts Served Donut Manager 35 2007 1 Catering Services Actual 10020 0 Number YTD
5 Donuts Served Donut Manager 42 2007 2 Catering Services Actual 10020 0 Number YTD
5 Donuts Served Donut Manager 86 2007 3 Catering Services Actual 10020 0 Number YTD
5 Donuts Served Donut Manager 14 2007 4 Catering Services Actual 10020 0 Number YTD
6 Donuts Cooked Donut Manager 45 2007 1 Catering Services Actual 10020 0 Number SUM
6 Donuts Cooked Donut Manager 48 2007 2 Catering Services Actual 10020 0 Number SUM
6 Donuts Cooked Donut Manager 93 2007 3 Catering Services Actual 10020 0 Number SUM
6 Donuts Cooked Donut Manager 32 2007 4 Catering Services Actual 10020 0 Number SUM
6 Donuts Cooked Donut Manager 18 2007 5 Catering Services Actual 10020 0 Number SUM
From what I understand from your question this is what I would do: 从您的问题中我了解到,这就是我会做的:
Assuming that when the aggregation type YTD returns the acumulated totals until (and including) the MonthNum. 假设当聚合类型YTD返回直到(包括)MonthNum的累计总数。
Create a Matrix with two a groups on KpiID and a child group on AggregationType, and two column groups (adjacent) one on the year and one on the month (on the year group, create a filter so that you don't include the current year and on the month group exclude the values where the year is not the current one). 创建一个矩阵,其中在KpiID上有两个分组,在AggregationType上有一个子分组,两个列组(相邻)分别在一年和一个月(在年分组)上,创建一个过滤器,以使您不包括当前的年份和月份组排除年份不是当前年份的值)。
Then you can use the following expression, for both the year and the month group (the last will give you the YTD value for the last month in each year) 然后,您可以对年份和月份组使用以下表达式(最后一个将为您提供每年最后一个月的YTD值)
=Switch(Fields!AggregationType.Value="SUM", Sum(Fields!ScoreValue.Value),
Fields!AggregationType.Value="AVG", Avg(Fields!ScoreValue.Value),
Fields!AggregationType.Value="YTD", Last(Fields!ScoreValue.Value))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.