2015-06-02 54 views
0

我的問題是如何通過MDX中的其他字段篩選有效字段。MDX篩選器級別的成員

我有一個表格:samples; 如果我使用SQL來解決問題,就像這樣:

select patient_id from samples where calc_test_type_id = 1; 

我創建了這個維度:患者特徵 層次:ID 級別:ID(樣品表患者ID),包括財產,命名爲「種皮','testA'鏈接到calc_test_type_id。

所以,我想MDX是這樣的:

SELECT 
{[Measures].[num_samples]} ON COLUMNS, 

{ 
    filter 
     (
     distinct([Patient characteristic.id].[id].members), 
     [Patient characteristic.id].CurrentMember.Properties("calc_type") = 1 
     ) 
} ON ROWS 
FROM [EIDCube] 

[Measures].[num_samples]是計算calc_test_type_id = 1多少行。

但我發現一些數據丟失。那麼如何找到所有合適的患者身份證?

+1

如果「[措施]。[num_samples]是計算calc_test_type_id = 1的行數「,爲什麼你仍然有過濾器?預期輸出是什麼?請儘可能添加示例。 – SouravA

+0

嗨,[措施]。[num_samples]只是爲了驗證過濾結果。我想過濾像sql這樣的patient_id:從calc_test_type_id = 1的樣本中選擇patient_id; –

回答

0

你的代碼看起來不錯。嘗試先創建集合。此外,我不認爲你需要不同的:

WITH SET [calc_type1] AS 
    FILTER 
     (
     [Patient characteristic.id].[id].members) 
     ,[Patient characteristic.id].CurrentMember.Properties("calc_type") = 1 
     ) 
SELECT 
    {[Measures].[num_samples]} ON 0, 
    [calc_type1] ON 1 
FROM [EIDCube]; 

要檢查回來我會忍不住先運行此腳本,而不該措施的設置,像這樣:

WITH SET [calc_type1] AS 
    FILTER 
     (
     [Patient characteristic.id].[id].members) 
     ,[Patient characteristic.id].CurrentMember.Properties("calc_type") = 1 
     ) 
SELECT 
    {} ON 0, 
    [calc_type1] ON 1 
FROM [EIDCube]; 
+0

我試過這個,但它不起作用。我想也許這個立方體在這個方面是錯誤的。在Patient特徵維度中,它具有id層次結構,id層次結構具有id級別,id級別列來自patient_id(樣本表),並且級別具有屬性'calc_type','calc_type'來自calc_test_type_id列(樣本表)。也許屬性列與id級別(patient_id列)鏈接錯誤。但我無法識別它。 –

+0

看來mondrian不能鏈接關卡成員,它是同一行的屬性。 –

+0

我發現我的問題,該屬性不支持n:n關係..非常感謝! –