Mdx - 标记 - 实际

3
我有两个维度DimFlag和DimPNL以及一个事实表FactAmount。我的目标是:当pnl处于状态(Is Stat=1)时:求和(Actual x FlagId)。对于pnl,我基本上通过字段FlagId将金额相乘,如果FlagId为0,则结果为0。
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)
);

“ftp” 命令是一个选项吗?或者至少有 “wget” 吗?我喜欢 “curl”,但我认为使用 “ftp” 或 “wget” 会更容易。 - npocmaka
如果需要的话,您可以设置代理:http://linuxers.org/tutorial/wget-proxy-how-run-wget-behind-proxy-server - npocmaka
如果“Is Stat”为0,应该得到什么结果?从这个计算中得出的度量应该如何命名? - FrankPl
2
你为什么要将一个关于Curl的完全不同的查询转变成一个关于MDX的查询呢? - FrankPl
1个回答

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*

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接