March 6, 2020

MDX, 29 февраля и Parallelperiod

Неплохой кейс, пишут что эффективный.

union 
(
    PARALLELPERIOD(
        [Date].[Fiscal Detail].[Fiscal Year],1,
        [Date].[Fiscal Detail].currentmember) 
    *(will be null if Feb 29)*
    ,
    PARALLELPERIOD(
        [Date].[Fiscal Detail].[Fiscal Year],1,
        [Date].[Fiscal Detail].currentmember.lag(1))  
    *(will be the prior year Feb 28 when above is Feb 29 )*    
).item(0)  *(get the first member out of the union set)*