Forum Discussion
vazmor
Helper II
8 years agoCompare 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...
- 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 )
vazmor
Helper II
8 years agohello if I tried it but it brings me the whole month and also brings me all the stores without distinction.
vazmor
Helper II
8 years agoSolution:
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
)