If you want to get the sales for last months then ParallelPeriod is your friend. The first difference is that ParallelPeriod gives you the option to go as many as intervals you want back or forward. Understanding this fact now we can answer this question: What is the difference between SamePeriodLastYear and ParallelPeriod? ParallelPeriod gives the result of a period parallel to this period (in the past or future), which is statically determined in the Interval parameter Can be Month, Quarter, or Year. This brings us to an important conclusion: ParallelPeriod can be used to fetch the Sales of last month like this: Parallel Period -1 Month = CALCULATE(Īs you can see in the above screenshot ParallelPeriod will return sales of the entire last month, even if you are looking at the day level. This is an example of using ParallelPeriod:įor every month, the ParallelPeriod expression will return a month before that, because in the parameters, we mentioned the month before: PARALLELPERIOD(DimDate., -1, MONTH ) and the number of intervals can be negative (to go to past), or positive (to go to the future). You can choose the interval to be Month, Quarter, or Year. you need three parameters for this function: You can navigate to periods in the past or future. ParallelPeriod is another function that gives you the ability to get the parallel period to the current period. SamePeriodLastYear function when used in a real-world scenario it will act as a filter, and you can get the Sales of the same period last year with that using an expression like this: Same Period Last Year = CALCULATE( If filter context is in DAY level it will return the same DAY last year, if the filter context is in Month level, it will return same Month last year. For Q4 of 2006 it will return Q4 of 2005. for 1st of Sep 2006, it will return date period of 1st of Sep 2005. SamePeriodLastYear returns the equivalent period to the filter context from last year. the screenshot below shows it įor example for September 2006, SamePeriodLastYear returns September 2005. If you filter context is at month level then you get the same month last year. SAMEPERIODLASTYEAR(DimDate.)Īs you can see in the screenshot above it shows that the SamePeriodLastYear returns the same date last year when your filter context is in day level. In the screenshot above I have used the SamePeriodLastYear inside a LastDate, and also a FirstDate to get the range of dates for each filter context selection. You have to use this function as a filter function. Means you cannot use it directly in a measure. The code above returns a table with one single column: date. this is how you can get this function working: SAMEPERIODLASTYEAR(DimDate.) The SamePeriodLastYear function like many other time intelligence functions needs a date field to work. The image below shows how the SamePeriodLastYear works for Date You can use the function simply just by providing a date field: If you are slicing and dicing in a month or quarter level this would give you the same month or quarter last year. Let’s start with the SamePeriodLastYear function this function will give you exactly what it explains same PERIOD but last year! same period means if you are looking at data on the day level, it would be same day last year. If you want to learn more about Power BI: read Power BI book from Rookie to Rock Star. Let’s take a look at these questions and their responses in more details through this post. and many other questions that lead to this final question: Which function should be used in which situation?.ParallelPeriod for a month vs DateAdd for a month ago.SamePeriodLastYear function vs using ParallelPeriod with Year parameter.Using DAX time intelligence functions for a while you may ask this question from yourself that what is the difference between functions below
0 Comments
Leave a Reply. |