Forum Discussion

vazmor's avatar
vazmor
Icon for Helper II rankHelper II
8 years ago
Solved

Compare Equivalent Period and sames Store Last Year

Hello everyone, I have the following problem, I want to compare the same time period for last year, if I have from 03/01/2018 to 03/21/2018, I need to compare in that period but for the 2017 but add...
  • vazmor's avatar
    vazmor
    8 years ago

    Solution:

     

    Sales Value LYD =
    VAR LastDaySelection =
        LASTNONBLANK (
            'Calendar'[Date],
            [Sales Value]
        )
    VAR CurrentRange =
        DATESBETWEEN (
            'Calendar'[Date],
            MIN ( 'Calendar'[Date] ),
            LastDaySelection
        )
    VAR CurrentStores =
        VALUES ( Sales[Store] )
    VAR PreviousRange =
        SAMEPERIODLASTYEAR ( CurrentRange )
    VAR _Last =
        CALCULATE (
            [Sales Value],
            PreviousRange,
            CurrentStores
        )
    RETURN
        IF (
            [Sales Value LY] = BLANK (),
            BLANK (),
            _Last
        )