2014-01-26 58 views
3

我有兩個維度DimFlag和DimPNL和一個事實表FactAmount。我期待:當pnl爲stat(Is Stat = 1)時:sum(Actual x FlagId) 對於pnl,我將FieldId的數量乘以基本上是否等於0 0 X = 0 ..Mdx - 標誌-Actual

DimFlag

FlagId FlagLabel 
----------------- 
1  NotClosed 
0  IsClosed 

DimPNL

PNLId PNLName Is Stat 
1  a  1 
2  test  1 
3  test2 0 

FactAmount

id PNLId  FlagId Actual 
    1  1  1  100 
    2  2  1  10 
    3  3  0  120 

我嘗試以下MDX,但它沒有工作,請任何想法嗎?

Scope (
     [Dim PNL].[PNL].members,[Measures].members  

); 


this = iif([Dim PNL].[PNL].CurrentMember.Properties("Is Stat") =1 
, 
aggregate([Dim PNL].[PNL].currentmember,[Measures].currentmember)* iif([Dim Flag].[Flag Label].[Flag Label].currentmember = 0, 0, 1), 
aggregate([Dim PNL].[PNL].currentmember,[Measures].currentmember) 
); 
+0

是'ftp'命令的一個選項嗎?或者至少在'wget'?我喜歡'curl',但我認爲使用'ftp'或'wget'會更容易 – npocmaka

+0

你可以設置一個代理,如果這是你想要的:http://linuxers.org/tutorial/wget-proxy-how-run- wget-behind-proxy-server – npocmaka

+0

如果'Stat'爲0,結果應該是什麼?應如何命名計算結果的度量? – FrankPl

回答

1

想不通你想什麼彙總(假設聚合功能只是執行默認彙總,可以計算或其他)。試試這個:

with 

-- check if PNL flag has IS_Stat = 1 value 
-- actually it is better to add IS_Stat as attribute, but nvm 
member isPNL as 
(
    iif([Dim PNL].[PNL].CurrentMember.Properties("Is Stat")=1,1,0) 
) 

-- calculate FlagID * Actual. May require leaf level calculation, but 
-- I am not sure without checking your cube structure 
member flagActualPair as 
(
    [Measures].[Actual] * CINT([Dim Flag].[Flag Label].[Flag Label].currentmember.memberValue) 
) 

-- get sum of Actual * FlagID 
member totalPNL as 
(
    sum(EXISTING [Dim PNL].[PNL].members, [Measures].[flagActualPair]) 
) 

-- final query - filter PNL axis, filtering out PNL's with IS_Stat = 0 
select 
{ 
    [Measures].[totalPNL] 
} on 0, 
{ 
    FILTER([Dim PNL].[PNL].allmembers, [Measures].[isPNL] = 1) 
} on 1 
from *YourCube*