Wednesday, April 22, 2020

DateAdd vs ParallelPeriod vs SamePeriodLastYear; DAX Time Intelligence Question

What is the difference between SamePeriodLastYear and ParallelPeriod?

The first difference is that ParallelPeriod gives you the option to go as many as intervals you want back or forward. If you want to get the sales for the last months; then ParallelPeriod is your friend. for calculating the sales of 2 years ago, then ParallelPeriod is your friend.
Dynamic Period is another difference between these two functions; If you think that the result of SamePeriodLastYear and the ParallelPeriod (when it is used with Year interval) are the same, continue reading. below is an example of these two measures:
For August 2006 for example; the SamePeriodLastYear gives us the sales of August 2005. However, the ParallelPeriod with year interval returns the sales for the entire year 2005.

DateAdd vs ParallelPeriod

Comparing these two functions with each other; you can see that DateAdd works on the period dynamically (like SamePeriodLastYear), but the ParallelPeriod works statically on the interval mentioned as the parameter.
That leads us to the conclusion that DateAdd(<date field>,-1, Year) is similar to SamePeriodLastYear, however, one difference is still there:

DateAdd vs SamePeriodLastYear

SamePeriodLastYear only goes one year back, DateAdd can go two years back or even more. DateAdd is a customized version of SamePeriodLastYear.

Conclusion

In summary, there are differences between these three functions:
  • DateAdd and SamePeriodLastYear both work based on the DYNAMIC period in the filter context
  • ParallelPeriod is working STATICALLY based on the interval selected in the parameter
  • ParallelPeriod and DateAdd can go more than one interval back and forward, while SamePeriodLastYear only goes one year back.
  • DateAdd works on the interval of DAY, as well as month, quarter and year, but ParallelPeriod only works on month, quarter, and year.
  • Depends on the filter context you may get a different result from these functions. If you get the same result in a year level context, it doesn’t mean that all these functions are the same! Look more into the detailed context.

No comments:

Post a Comment

Sort by Month and year in the table

  Solved: Sort by month in Power BI - Microsoft Power BI Community