此查询中的计算所得成员[金额LM](=上个月的金额)有什么问题?如果我在行上指定时间,这似乎可以工作,但是即使我在where子句中有一个日期,也可以指定失败的时间。
WITH
MEMber [Amount LM] as
(
[Measures].[Amount],ParallelPeriod (
[Date].[Year - Quarter - Month - Date - Hierarchy].[Year and Month],1,[Date].[Year - Quarter - Month - Date - Hierarchy].CurrentMember
)
)
SELECT
{[Amount LM],[Measures].[Amount]} ON COLUMNS,[Measure Types].[Name].&[22] --not related to [Measures].[Amount]; Used as a measure switch in the real case but adjusted here for simplicity
-- comment out the next line to fail
* [Date].[Year - Quarter - Month - Date - Hierarchy].[Year and Month]
ON rows
FROM [Cube]
WHERE [Date].[Year Number].&[2019]
;
得出工作案例:
Amount LM | Amount
Costs | Jan 2019 | (null) | 109600
Costs | Feb 2019 | 109600 | 218300.5
Costs | Mar 2019 | 218300.5 | 392250
Costs | Apr 2019 | 392250 | 206800
Costs | May 2019 | 206800 | 174700
Costs | Jun 2019 | 174700 | 298400
Costs | Jul 2019 | 298400 | 264550
Costs | Aug 2019 | 264550 | 424100
Costs | Sep 2019 | 424100 | 129650
Costs | Oct 2019 | 129650 | 330050
Costs | Nov 2019 | 330050 | (null)
Costs | Dec 2019 | (null) | (null)
没有
* [Date].[Year - Quarter - Month - Date - Hierarchy].[Year and Month]
零件,LM量为空
|Amount LM| Amount
Costs | (null) | 2548400.5