2012-10-01 38 views
1

我有一份Reporting Services報告,其中顯示了一組KPI分數。每個KPI在報告中都有它自己的Row,並且對於每一行,我們都會顯示過去3年的SUM或AVG(取決於KPI類型)分數,然後顯示當年的SUM,AVG或(理想情況下)每月總YTD數字:在SSRS報告中獲得年份/年份/過濾列組的年度至今數據

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 

我看到的問題是,RunningValue功能似乎是跨行的工作,而不是使了一月,二月,三月列(每月過濾的列組和當前行內數據,按年份和月份分組,按當年進行過濾)。所以輸出不像上面那樣,而是基於行中所有值的相當隨機的數字(我確定它不是隨機的,它看起來就像是這樣)。

列組被稱爲「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")) 

任何幫助非常讚賞

更新: 下面是使用數據集的幾行(每月分數,每kpi)的示例(格式化有點棘手!)。與aggragation型「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 
+0

你能告訴樣品(幾行)你的數據集? –

回答

1

從我從你的問題該明白的是我會做什麼:

假設當聚合類型YTD返回累計總數直到(幷包括)MonthNum。

在KPIID和AggregationType上的一個子組上創建一個矩陣,並在年份和月份上創建兩個列組(相鄰)(年份組中創建一個過濾器,包括當年和本月組不包括年份不是當前值的值)。

然後你可以用下面的表達式,年份和月份團都爲(最後會給你在每一年的最後一個月的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)) 
+0

AggregationType是最終報告中該KPI的請求類型。數據源值是原始月度分數(未彙總)。因此,從本年度起,報告必須完成計算本年迄今運行總量的工作。 –

+0

我一直在努力做你想做的事,我無法讓它工作。你會考慮改變你的查詢,以便YTD值已經是累計值嗎? –

+1

您好Joao,不,我希望報告服務來根據需要進行彙總原始數據的工作。我敢打賭,Crystal Reports的夥計們會對自己應該是​​多麼容易咯咯笑起來。我真的希望使用RunningValue的表達式能夠正常工作。也許我需要一個報告代碼級別的函數來執行聚合和跟蹤行號,但我不想要任何複雜的東西。 –