本文介绍了如何在MDX中获得最后的卖价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
MDX是否可以按照以下代码返回预期结果?具有以下数据:
Can MDX return the Expected Result as per code below? Have the data as per below :
DATA:
ItemID DateKey Price
A 20151230 4.85
A 20150520 5.5
A 20150325 4.65
B 20140130 3
B 20141130 5
B 20150630 4.5
Wrong Result:
ItemID DateKey Price
A 20151230 4.65
B 20150630 3
Expected Result:
ItemID DateKey Price
A 20151230 4.85
B 20150630 4.5
WITH MEMBER [LastDate] AS tail (Filter([BI Dim Date].[Date Key].[Date Key],[Measures].[PRICE])).Item(0).name
MEMBER [LastDateWithSales] AS Filter([MyTest].[PRICE].[PRICE],[Measures].[LastDate]).Item(0).name
SELECT { [LastDate], [LastDateWithSales]} ON columns,
[MyTest].[ITEMID].[ITEMID] on rows
FROM [MyCube]
执行上述MDX,但结果错误.请告知.
Execute the above MDX but get wrong result. Please advise.
推荐答案
WITH MEMBER [LastDate] AS
tail (
NonEmpty(
[BI Dim Date].[Date Key].[Date Key].Members
,[Measures].[PRICE]
)
).Item(0).Item(0).name
MEMBER [LastDateWithSales] AS
tail (
NonEmpty(
[BI Dim Date].[Date Key].[Date Key].Members
* [Measures].[PRICE]
)
).Item(0)
SELECT
{ [Measures].[LastDate], [Measures].[LastDateWithSales]} ON columns,
[MyTest].[ITEMID].[ITEMID] on rows
FROM [MyCube]
这篇关于如何在MDX中获得最后的卖价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!