2013-03-29 88 views
1

我正在開發一個使用SSRS矩陣控制的報告。如何在ssrs矩陣報告中實現這一點

這是與我同

funmix

和在這裏工作的一個示例表是我試圖在SSRS

Results

OK的使用矩陣工具來實現現在描述

該報告需要圖片類型A,B,C及其案例數量分組我噸由地點代碼。第6行將包含從第4行和第5行(類型A和類型B)派生的計算值。

由於它是所示的int截圖用於導出結果($ 44)式是通過使用公式

(Case Value of Type B * average of Type B) + (Case Value of Type C * average of Type C) 
------------------------------------------------------------------------------------- 
          (Case Value of Type B + Case Value of Type C) 

這樣的$ 44值,可以實現作爲

(57 * 18) + (44 * 78)/(57 + 44) 

可以有人請求指導我如何在ssrs中實現這一點。 我做了結構,但無法計算總價值。

回答

1

這取決於你如何得到你的平均值。這是發生在幕後,你預定了什麼,或者你是基於你可以加入的其他表來做它嗎?

我會做到這一點,如果它是所有數據集可以得到:

  1. 確定的數據集,既您的數據和平均值。我不確定你是從SQL發起還是隻在Excel中完成這一切。我將在SQL假人暫且:

    declare @Avgs Table (location int, type varchar(1), cs int, average int); 
    
    insert into @Avgs values (1, 'A', 21, 10),(1, 'B', 57, 18),(1, 'C', 44, 78); 
    
    Select top 10 * 
    from @Avgs 
    
  2. 你可能想增加一個「計算列」或做數學題,直接在SQL中SSRS表達式編輯器一般是沒事的東西都是一個函數或者兩個,但是當你涉及數學時,我發現SQL引擎更好地處理它。這也使得稍後改變事情變得更好。

  3. 所以我會修改SQL這樣:

    declare @Avgs Table (location int, type varchar(1), cs int, average int); 
    
    insert into @Avgs values (1, 'A', 21, 10),(1, 'B', 57, 18),(1, 'C', 44, 78); 
    
    With a as 
        (
        select *, cs * average as compound 
        from @Avgs 
        ) 
    , b as 
        (
        Select 
         (max(case when type = 'B' then compound end) + max(case when type = 'C' then compound end))/
         (max(case when type = 'B' then cs end) + max(case when type = 'C' then cs end)) as CompoundMath 
        from a 
        ) 
    select * 
    from a, b 
    
  4. 這將是SSRS數據集中,複合功能後,可以改變這樣的內部(情況下...完) '當'是邏輯時,'後'是什麼結果。

  5. 只需添加一個新行,您就可以將自定義表達式設置爲名爲「複合數學」的列。