2015-08-24 47 views
1

我有以下MDX查詢:MDX該如何實現?

SELECT NON EMPTY { [Measures].[FlowAmount] } ON COLUMNS, 

NON EMPTY { ([Dim Date].[Fiscal].[Fiscal Quarter].ALLMEMBERS * [TransferCase].[Tfr Case Ref].[Tfr Case Ref].ALLMEMBERS * [Dim Wrappers].[Fac Group].[Fac Group].ALLMEMBERS) } ON ROWS

FROM (SELECT ({ [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14] }) ON COLUMNS

FROM [Cube])

它返回如下:

Q1 TF1 GIA 1000

Q1 TF2 GIA 2500

Q1 TF3 ISA 100

Q1 TF4 GIA 100

我怎樣才能被FAC集團獲得總和生育率案例參考文獻的數量和總計流量?

Q1 GIA 3 2600

Q1 ISA 1 100

所以在SQL Select Fiscal Quarter, Fac Group , count(distinct TfrCaseRef), Sum(FlowAmount) Group by Fiscal Quarter, Fac Group

TransferCase是基於事實表一個事實維度含有FlowAmount量度。

回答

0

這可能工作:

WITH MEMBER Measures.[Count Refs] AS 
    COUNT(
    Distinct(
    EXISTING [TransferCase].[Tfr Case Ref].[Tfr Case Ref].Members 
    ) 
) 
SELECT 
NON EMPTY 
    { 
    [Measures].[FlowAmount] 
    ,Measures.[Count Refs] 
    } ON COLUMNS, 
NON EMPTY 
    DESCENDANTS(
    [Dim Date].[Fiscal].[Fiscal Year].&[FY 13/14] 
    , [Dim Date].[Fiscal].[Fiscal Quarter] 
) 
    *[Dim Wrappers].[Fac Group].[Fac Group].ALLMEMBERS 
    ON ROWS 
FROM [Cube]; 

我使用DESCENDANTS函數來獲取所有相關的13/14財年的宿舍。希望比子查詢更容易閱讀。