我一直在进行查询以获取 MDX 中上一年的值,但无法获得所需的输出。在sql中我会这样做。问题是如何在 MDX 中应用此查询?
select data1, sum(data2) as sumthisyear, sumlastyear from table1 a left outer join ( select data1, sum(data2) 'sumlastyear' from table1 where tableyear = 2017 group by data1 ) b on a.data1 = b.data1 where tableyear= '2018' and datafilter = 'SampleFilter' group by data1, sumlastyear
我做了一些研究,并做了类似 parallelperiod 的 mdx 函数,但没有给出正确的值,因为数据是根据 2018 年过滤的。
这是我的 MDX 查询
CREATE MEMBER CURRENTCUBE.Measures.[SPLY Registered Sales] AS
iif( [DimProdDate].[Dates].CurrentMember Is
[DimProdDate].[Dates].[All].LastChild,
( PARALLELPERIOD( [DimProdDate].[Dates].[Calendar Year],
1,
Tail( NonEmpty( [DimProdDate].[Dates].[Full Date].MEMBERS,
[MEASURES].[Registered Sales]),
1
).Item(0)
),
[MEASURES].[Registered Sales] ),
( PARALLELPERIOD( [DimProdDate].[Dates].[Calendar Year],
1,
[DimProdDate].[Dates].CurrentMember
),
[MEASURES].[Registered Sales] )
);
任何帮助将不胜感激。
谢谢!