Forum Discussion
ParallelPeriod not Working as Expected
- 7 years ago
After dinner out with my wife and friends, coming home and having a whiskey, it crossed my mind to try:
Prev Month Qty (Parallel Period) = CALCULATE([Qty This Month], PARALLELPERIOD('Date'[Date], -1, MONTH))The difference is putting the measure [Qty This Month] as the first argument instead of SUM('Sales'[Quantity]) in the CALCULATE function. This calculated precisely the result I wanted! And, I realized I've done something similar before. I think I just needed to step away for a bit.
My reasoning is that if you don't use an existing measure which uses time intelligence as the first argument (such as MTD), it has no idea what period it should parallel. By specifying the original measure with MTD, it knows what month and can determine what the parallel period is.
I think your formula is fine.
The problem is you are telling DAX to calculate the total of the previous month when the date range is 5/1/2014 - 9/22/2017, so it is adding everything up from 4/1/2014 - 8/31/2017.
If you want it to return the previous month from the last selected month, try this:
Penultimate Month Quantity =
CALCULATE (
[Total Quantity],
FILTER (
'Date',
'Date'[Month Number] = MONTH ( EOMONTH ( MAX ( 'Date'[Date] ), -1 ) )
)
)By the way, this is ugly and I don't like it, but it works. I'd spend another half hour making it more logical but I don't have another half hour right now. :smileywink:
I recommend you put a temporary TABLE or MATRIX on your page that has the following:
YearMonth field
Total Quantity Measure:
Total Quantity = SUM(Sales[Quantity])
Previous Month Quantity Measure:
Previous Month Quantity =
CALCULATE(
[Total Quantity],
PARALLELPERIOD('Date'[Date],-1,MONTH)
)You can watch the table grow/shrink as you move the slider, and can see what the Penulatament Month Quantity should be.
- jdballard307 years agoHelper II
After dinner out with my wife and friends, coming home and having a whiskey, it crossed my mind to try:
Prev Month Qty (Parallel Period) = CALCULATE([Qty This Month], PARALLELPERIOD('Date'[Date], -1, MONTH))The difference is putting the measure [Qty This Month] as the first argument instead of SUM('Sales'[Quantity]) in the CALCULATE function. This calculated precisely the result I wanted! And, I realized I've done something similar before. I think I just needed to step away for a bit.
My reasoning is that if you don't use an existing measure which uses time intelligence as the first argument (such as MTD), it has no idea what period it should parallel. By specifying the original measure with MTD, it knows what month and can determine what the parallel period is.