2015-08-28 61 views
0

我有一個MDX查詢看起來像這樣:MDX - 行數爲1後訂購

WITH 
SET selection as ([Dates].[Year].&[2014],[Dates].[Month].&[1])   
set testset as (selection, [ThroughputID].[ID].ALLMEMBERS) 

MEMBER [Measures].[RowCount] AS COUNT (testset) 

SELECT 
selection ON 0, 
[Measures].RowCount 
ON 1 
FROM (SELECT [Dates].[Y-H-Q-M].MEMBERS ON 0 FROM [Throughput]) 

行數給出1182918

如果我添加以「測試集」像下面,行數給出1,如何來?

WITH 
SET selection as ([Dates].[Year].&[2014],[Dates].[Month].&[1])   
set testset as ORDER(selection, [ThroughputID].[ID].ALLMEMBERS) 

MEMBER [Measures].[RowCount] AS COUNT (testset) 

SELECT 
selection ON 0, 
[Measures].RowCount 
ON 1 
FROM (SELECT [Dates].[Y-H-Q-M].MEMBERS ON 0 FROM [Throughput]) 
+0

驚訝它實際運行 - 這是一個非常奇怪的第二個參數爲ORDER函數[吞吐量]。[ID] .ALLMEMBERS' – whytheq

+0

你想用該命令實現什麼? – mxix

+0

我想創建一個Quartiles的計算,如果我理解了所有正確的設置需要排序才能做到這一點。 – supremo

回答

1

請試試這個,然後你可以檢查數據,瞭解變化:

WITH 
    SET selection AS 
    (
     [Dates].[Year].&[2014] 
    ,[Dates].[Month].&[1] 
    ) 
    SET testset AS 
    Order 
    (
     selection 
    ,[ThroughputID].[ID].ALLMEMBERS 
    ) 
SELECT 
    {} ON 0 
,testset ON 1 
FROM 
(
    SELECT 
    [Dates].[Y-H-Q-M].MEMBERS ON 0 
    FROM [Throughput] 
); 

我懷疑你的腳本的這部分失敗和解決的一個成員:

Order 
    (
     selection 
    ,[ThroughputID].[ID].ALLMEMBERS 
    ) 

訂單的第二個參數通常是數字 - 你已經使用了一個集合。