简体   繁体   中英

MDX SSAS 2008 Last year calculation - Leap year issue

I have calculation which calculates the value from previous year, realized in following way:

([Measures].[SalesAmount LY], Leaves([Time])) = 
(
     PARALLELPERIOD
     (
          [Time].[Year - Month - Day].[Year],
          1,
          [Time].[Year - Month - Day].currentmember
     ), 
     [MEASURES].[SalesAmount]
 )

I am doing it this way, because using only PARALLELPERIOD results in incorrect total calculations when selecting only some months for example. And it works just fine.

However, now I am facing following issue with leap year:

Month         SalesAmount  SalesAmount LY
------------- ------------ ---------------
January 2012  1000
February 2012 1100         --Leap year - 29.February
January 2013  1200         1000
February 2013 1300         1050

The missing value (1100 - 1050 = 50 in this case) is exactly equal to the value from 29.2.2012.

Does anyone have an idea how to solve this issue? How to get leap year working correctly, while still maintaining correct totals behavior? Any help would be greately appreciated.

This can help?

PARALLELPERIOD
(
  [Time].[Year - Month - Day].[Year],
  1,
  ISLEAF([Time].[Year - Month - Day].currentmember),
  Ancestor([[Time].[Year - Month - Day].currentmember, [Time].[Year - Month - Day].[Month]),
  [Time].[Year - Month - Day].currentmember)
), 
[MEASURES].[SalesAmount]

if the current member is a Day, it will refer to his month parent, so it doesn't matter if the month has 28 or 29 days.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM