Hi,
How to calculate the month to date period for the same period last year.
Eg. If today is 13/05/2021 (Current Month to Date) how do I calculate what sales was for 1/05/2020 to 13/05/2020?
I managed to do this with the calculated item below:
IF ( ( Month('DATE X'n) = Month(DatePart(Now())) ) AND (
Year('DATE X'n) = Year(DatePart(Now()))-1 ))
DayOfMonth('DATE X'n) <= DayOfMonth(DatePart(Now())) ) )
RETURN 'VAUE X'n
ELSE 0
Hello,
You would use the ParallelPeriod operator in a calculated item.
Here is an example that should calculate the month-to-date value for the previous year:
ParallelPeriod(_Sum_, 'Expenses'n, _ApplyAllFilters_, 'Date'n, _ByMonth_, _ByYear_, -1, _ToDate_)
The last parameter above specifies the "to date" part.
The UI for the periodic operators in the graphical expression editor is a bit confusing, so refer to the doc and the tooltips.
Let us know how it goes.
Thanks,
Sam
Getting only a specific month is actually a bit trickier.
The easiest way might be to precalculate the value in your source table.
I am making some inquiries about a way to do it within VA.
Sam
I managed to do this with the calculated item below:
IF ( ( Month('DATE X'n) = Month(DatePart(Now())) ) AND (
Year('DATE X'n) = Year(DatePart(Now()))-1 ))
DayOfMonth('DATE X'n) <= DayOfMonth(DatePart(Now())) ) )
RETURN 'VAUE X'n
ELSE 0
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.