2017-07-25 195 views
0

我是MDX的新手,我有一個小問題,希望他們能幫助我。Total MDX查詢

我有以下查詢分析圖表:

WITH 
    MEMBER [Articulo].[Art_Linea].[ Aggregation] AS 
    Aggregate({[Articulo].[Art_Linea].&[3M],[Articulo].[Art_Linea].&[Bendix]}) 
    ,SOLVE_ORDER = 0 
SELECT 
    Hierarchize 
    (
     { 
     [Almacen].[Alm_Nombre].&[MATRIZ] 
     ,[Almacen].[Alm_Nombre].&[TOLUCA] 
     } 
    ) 
    * 
    { 
     [Measures].[Val] 
    ,[Measures].[Disponible] 
    } ON COLUMNS 
,Hierarchize 
    (
    { 
     [Articulo].[LCD].[Art_Linea].&[3M] 
    ,[Articulo].[LCD].[Art_Linea].&[Bendix] 
    } 
) ON ROWS 
FROM [Inventario] 
WHERE 
    [Articulo].[Art_Linea].[ Aggregation] 
CELL PROPERTIES 
    VALUE 
,FORMATTED_VALUE 
,CELL_ORDINAL 
,FONT_FLAGS 
,FORE_COLOR 
,BACK_COLOR; 

它返回下面的網格:

Analytic Chart

我想用的總和添加一個「總計」欄每個「Articulo LCD」的「MATRIZ」和「TOLUCA」欄的「Val」和「Disponible」措施。

你能指導我如何做到這一點嗎?我不知道如何實現「總和」功能。

非常感謝你。

問候!

回答

0

也許試試這個:

WITH 
    MEMBER [Articulo].[Art_Linea].[ Aggregation] AS 
    Aggregate({[Articulo].[Art_Linea].&[3M],[Articulo].[Art_Linea].&[Bendix]}) 
    ,SOLVE_ORDER = 0 
    MEMBER [Articulo].[LCD].[All].[3M+Bendix] AS //<<you might need to play around here - maybe this is correct name?: [Articulo].[LCD].[All].[Art_Linea].[3M+Bendix] 
    Sum 
    (
     { 
     [Articulo].[LCD].[Art_Linea].&[3M] 
     ,[Articulo].[LCD].[Art_Linea].&[Bendix] 
     } 
    ) 
SELECT 
    Hierarchize 
    (
     { 
     [Almacen].[Alm_Nombre].&[MATRIZ] 
     ,[Almacen].[Alm_Nombre].&[TOLUCA] 
     } 
    ) 
    * 
    { 
     [Measures].[Val] 
    ,[Measures].[Disponible] 
    } ON COLUMNS 
,Hierarchize 
    (
    { 
     [Articulo].[LCD].[Art_Linea].&[3M] 
    ,[Articulo].[LCD].[Art_Linea].&[Bendix] 
    ,[Articulo].[LCD].[All].[3M+Bendix] //<<you might need to play around here - maybe this is correct name?: [Articulo].[LCD].[All].[Art_Linea].[3M+Bendix] 
    } 
) ON ROWS 
FROM [Inventario] 
WHERE 
    [Articulo].[Art_Linea].[ Aggregation]; 

雖然我有點不確定的聚集成員的目的 - 這樣也許只是下面?

WITH 
    MEMBER [Articulo].[LCD].[All].[3M+Bendix] AS //<<you might need to play around here - maybe this is correct name?: [Articulo].[LCD].[All].[Art_Linea].[3M+Bendix] 
    Sum 
    (
     { 
     [Articulo].[LCD].[Art_Linea].&[3M] 
     ,[Articulo].[LCD].[Art_Linea].&[Bendix] 
     } 
    ) 
SELECT 
    Hierarchize 
    (
     { 
     [Almacen].[Alm_Nombre].&[MATRIZ] 
     ,[Almacen].[Alm_Nombre].&[TOLUCA] 
     } 
    ) 
    * 
    { 
     [Measures].[Val] 
    ,[Measures].[Disponible] 
    } ON COLUMNS 
,Hierarchize 
    (
    { 
     [Articulo].[LCD].[Art_Linea].&[3M] 
    ,[Articulo].[LCD].[Art_Linea].&[Bendix] 
    ,[Articulo].[LCD].[All].[3M+Bendix] //<<you might need to play around here - maybe this is correct name?: [Articulo].[LCD].[All].[Art_Linea].[3M+Bendix] 
    } 
) ON ROWS 
FROM [Inventario]; 
+0

感謝以下兩件事:縮進我的代碼,並向我展示MDX語言更加清晰,並向我展示如何使用「SUM」函數。 我想要做的是的措施「瓦爾」的總和,併爲每一行的所有列的「Disponible」,這樣的事情: http://i.imgur.com/7vR06rC.png 我怎麼能這樣做? 感謝您的任何建議! 此致! –

+0

事實上,「Aggregation」成員在我的代碼中被遺忘了!謝謝! –