使用 LinkMember 函数获取所有链接成员
Get All Linked Members using LinkMember function
请考虑这个结构:
事实:
Sender Receiver Amount
----------------------------------------
Reseller1 Resseler2 100
Reseller1 Resseler3 200
Reseller3 Resseler1 150
Reseller3 Resseler2 50
Reseller1 Resseler4 100
Reseller4 Resseler2 350
Reseller4 Resseler1 500
Reseller4 Resseler3 250
DimReseller:
ResellerCode ResellerName
---------------------------------------
1 Reseller1
2 Reseller2
3 Reseller3
4 Reseller4
DimReseller
是角色扮演维度,与事实有2个关系table:
现在我将这个 MDX
查询写到 select 经销商互相支付了多少钱:
WITH MEMBER SenderAmount AS
[Measures].[Amount], FORMAT_STRING = "Standard"
SELECT {SenderAmount} ON 0,
NON EMPTY [Sender].[Hierarchy].MEMBERS ON 1
FROM [MyCube]
我得到了这个结果:
现在我想知道经销商从彼此那里收到了多少钱,我写了这个查询:
WITH
MEMBER SenderAmount AS
[Measures].[Amount], FORMAT_STRING = "Standard"
MEMBER ReceiverAmount AS
(LinkMember
([Sender].[Hierarchy].CurrentMember, [Receiver].[Hierarchy])
,[Measures].[Amount]), FORMAT_STRING = "Standard"
SELECT {SenderAmount, ReceiverAmount} ON 0,
NON EMPTY [Sender].[Hierarchy].MEMBERS ON 1
FROM [MyCube]
得到这个结果:
我得到了 null
的接收金额。我测试了这个 MDX
查询:
select {LinkMember([Sender].[Hierarchy].[Reseller Code].&[1], [Receiver].[Hierarchy])} on 0
from [MyCube]
我得到 650(正确的数量)Reseller1
。现在当我这样更改查询时:
select {LinkMember([Sender].[Hierarchy].currentmember, [Receiver].[Hierarchy])} on 0,
[sender].[Hierarchy].members on 1
from [MyCube]
我得到这个结果(同样是付费的):
当我以这种方式更改查询时:
select {LinkMember([Sender].[Hierarchy].currentmember, [Receiver].[Hierarchy])} on 0,
[receiver].[Hierarchy].members on 1
from [MyCube]
我收到这个错误:
The Hierarchy hierarchy already appears in the Axis0 axis.
我怎样才能得到这个结果?
Reseller Received Paind
--------------------------------------------------------
Reseller1 650 400
Reseller2 500 (null)
Reseller3 450 200
Reseller4 100 1100
抱歉解释太多...
谢谢
尝试以下更改:
MEMBER ReceiverAmount AS
(LinkMember
([Sender].[Hierarchy].CurrentMember, [Receiver].[Hierarchy])
,[Measures].[Amount]
,[Sender].[Hierarchy].[All]), FORMAT_STRING = "Standard"
请考虑这个结构:
事实:
Sender Receiver Amount
----------------------------------------
Reseller1 Resseler2 100
Reseller1 Resseler3 200
Reseller3 Resseler1 150
Reseller3 Resseler2 50
Reseller1 Resseler4 100
Reseller4 Resseler2 350
Reseller4 Resseler1 500
Reseller4 Resseler3 250
DimReseller:
ResellerCode ResellerName
---------------------------------------
1 Reseller1
2 Reseller2
3 Reseller3
4 Reseller4
DimReseller
是角色扮演维度,与事实有2个关系table:
现在我将这个 MDX
查询写到 select 经销商互相支付了多少钱:
WITH MEMBER SenderAmount AS
[Measures].[Amount], FORMAT_STRING = "Standard"
SELECT {SenderAmount} ON 0,
NON EMPTY [Sender].[Hierarchy].MEMBERS ON 1
FROM [MyCube]
我得到了这个结果:
现在我想知道经销商从彼此那里收到了多少钱,我写了这个查询:
WITH
MEMBER SenderAmount AS
[Measures].[Amount], FORMAT_STRING = "Standard"
MEMBER ReceiverAmount AS
(LinkMember
([Sender].[Hierarchy].CurrentMember, [Receiver].[Hierarchy])
,[Measures].[Amount]), FORMAT_STRING = "Standard"
SELECT {SenderAmount, ReceiverAmount} ON 0,
NON EMPTY [Sender].[Hierarchy].MEMBERS ON 1
FROM [MyCube]
得到这个结果:
我得到了 null
的接收金额。我测试了这个 MDX
查询:
select {LinkMember([Sender].[Hierarchy].[Reseller Code].&[1], [Receiver].[Hierarchy])} on 0
from [MyCube]
我得到 650(正确的数量)Reseller1
。现在当我这样更改查询时:
select {LinkMember([Sender].[Hierarchy].currentmember, [Receiver].[Hierarchy])} on 0,
[sender].[Hierarchy].members on 1
from [MyCube]
我得到这个结果(同样是付费的):
当我以这种方式更改查询时:
select {LinkMember([Sender].[Hierarchy].currentmember, [Receiver].[Hierarchy])} on 0,
[receiver].[Hierarchy].members on 1
from [MyCube]
我收到这个错误:
The Hierarchy hierarchy already appears in the Axis0 axis.
我怎样才能得到这个结果?
Reseller Received Paind
--------------------------------------------------------
Reseller1 650 400
Reseller2 500 (null)
Reseller3 450 200
Reseller4 100 1100
抱歉解释太多...
谢谢
尝试以下更改:
MEMBER ReceiverAmount AS
(LinkMember
([Sender].[Hierarchy].CurrentMember, [Receiver].[Hierarchy])
,[Measures].[Amount]
,[Sender].[Hierarchy].[All]), FORMAT_STRING = "Standard"