#powerbi #sameperiodlastyear #parallelperiod #dax #powerbitraining
This video points out the differences between parallelperiod and sameperiodlastyear .It is a continuation of my Power BI DAX Tutorial.
SAMEPERIODLASTYEAR returns a table containing a date column just shifted one year back .
See the use of the word PERIOD in this function .
Hence it can be used to get the Sales for:
1.One year back or
2.Same Quarter Previous Year
3.Same Month Previous Year
The syntax for this function is as follows:
SAMEPERIODLASTYEAR(dates)
Dates – A column that contains dates.
PARALLELPERIOD DAX function enables you to get the parallel period with respect to the current period. You can either travel to the future (months /qtr/year) or the past (months /qtr/year). This function has the below syntax and accepts 3 mandatory parameters.
Syntax :ParallelPeriod(date field, number of intervals, interval)
Date Filed is the column on which your date dimension is based .No of intervals to be Month, Quarter, or Year. and the number of intervals can be -ve (for past), or +ve (for future).The interval itself can be MONTH , QUARTER OR YEAR
Explanation of PARALLELPERIOD in Power BI desktop
Our main aim here is to create a measure to get the sales for previous month .I have created a simple dax using PARALLELPERIOD function to achieve this
Parallel Period (Last Month) = CALCULATE(
sum(Sales[Sales Amount]),
PARALLELPERIOD(‘Date'[Date],-1,MONTH)
)
Do watch this video where I have also clearly explained the differences between arallelperiod and sameperiodlastyear.
Now since we know how these two functions behave we can easily differentiate between them.
Difference 1: Parallelperiod lets to traverse both forward and backward in time while SamePeriodLastYear lets you calculate period only one year back .
Difference 2: I would say that Parallelperiod can be computed for any no of months /Years provided correct data resides in DWH. .May seem like a weird requirement but For example even if you want to see the sales for past 45 months .Its possible using the paralelperiod dax as shown below
PARALLELPERIOD(‘Date'[Date],-45,MONTH)
Difference 3 :Parallelperiod is bound by the intervals we give .So if you give month as interval it will return you the monthly Sales and if you give year as interval you will get Yearly Sales .So be very careful in using this since if you are having a visual at a day level (as shown above) its not advisable to use paralleperiod to get the daily Sales for previousyear .For this scenario you can use SameperiodLastYear .
Do watch and give your feedback!
Ещё видео!