我正在尝试使用MDX查询SSAS多维数据集,我有一个在多维数据集中排序的数值列表,我想引用多维数据集中的相邻单元格以返回值。
WITH MEMBER Measures.[LastShift]<br>
AS<br>
(<br>
[Measures].[Impact Value GBP], <br>
[Dim Shift].[Shift Value1].PrevMember<br>
)<br>
MEMBER Measures.[NextShift]<br>
AS<br>
(<br>
[Measures].[Impact Value GBP], <br>
[Dim Shift].[Shift Value1].NextMember<br>
)<br>
SELECT <br>
{NONEMPTY([Measures].[Impact Value GBP]), <br>
Measures.LastShift,<br>
Measures.NextShift<br>
}<br>
ON 0,<br>
NONEMPTY([Dim Shift].[Shift Value1].[Shift Value1])<br>
ON 1<br>
FROM [factTradeValues]<br>
我可以在RDBMS中看到我确实有相邻的值,但我不能让MDX返回除null之外的任何内容。也许我很厚,但看不到解决方案。
感谢您的帮助
答案 0 :(得分:1)
PrevMember和NextMember是“成员函数”所以你需要做这样的事情......
WITH
MEMBER Measures.[LastShift] AS
(
[Dim Shift].[Shift Value1].CurrentMember.PrevMember,
[Measures].[Impact Value GBP]
)
MEMBER Measures.[NextShift] AS
(
[Dim Shift].[Shift Value1].CurrentMember.NextMember,
[Measures].[Impact Value GBP]
)
答案 1 :(得分:0)
为了回答我自己的问题,结果是prevmember和nextmember的问题,因为我想在我的标准的上下文中轮流参考下一个项目。我实际上想参考我的集合中的下一个项目,这是微妙的不同。
为了引用集合中的项目,您使用项目,然后我使用排名来获取相邻单元格。
/* Define the shifts appropriate for this scenario */
SET [SpotShifts] AS
EXCEPT(
NONEMPTY([Dim Shift].[Shift Value1].[Shift Value1].MEMBERS,
(
[Dim Shift Entity].[Shift Entity].[GBP/FTSE],
[Dim Date].[Date].[Date].&[20120305],
{PriceImpacts
}
,[Dim Instrument].[Arena Name].[CO/GBP/Lch10/FTSE/140908/Inc_Quarter/5L]
)),[Dim Shift].[Shift Value1].&[0])
MEMBER Measures.CurrentSpotShift
AS
StrToValue([Dim Shift].[Shift Value1].CURRENTMEMBER.NAME)
MEMBER Measures.NextSpotShift AS
IIF((Measures.CurrentSpotShift<0),
SpotShifts.Item(RANK([Dim Shift].[Shift Value1].CURRENTMEMBER,SpotShifts)-2).NAME,
SpotShifts.Item(RANK([Dim Shift].[Shift Value1].CURRENTMEMBER,SpotShifts)).NAME)
MEMBER Measures.PreviousSpotShift AS
IIF((Measures.CurrentSpotShift<0),
SpotShifts.Item(RANK([Dim Shift].[Shift Value1].CURRENTMEMBER,SpotShifts)).NAME,
SpotShifts.Item(RANK([Dim Shift].[Shift Value1].CURRENTMEMBER,SpotShifts)-2).NAME)
MEMBER Measures.NextValue AS
IIF(Measures.CurrentSpotShift>0,
([Measures].[Impact Value],SpotShifts.Item(RANK([Dim Shift].[Shift Value1].CURRENTMEMBER,SpotShifts))),
([Measures].[Impact Value],SpotShifts.Item(RANK([Dim Shift].[Shift Value1].CURRENTMEMBER,SpotShifts)-2))
SELECT { NONEMPTY([Measures].[Impact Value]),
(Measures.PreviousSpotShift),
(Measures.LastValue),
(Measures.NextSpotShift),
(Measures.NextValue)} ON 0,
NONEMPTY(SpotShifts) ON 1
FROM factTradeCube
我希望这对某些人有所帮助,因为我发现在项目中使用排名并不是一个明显的解决方案,但是唯一能让我得到正确结果的人。