Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jdballard30
Helper II
Helper II

ParallelPeriod not Working as Expected

I am using ParallelPeriod and not getting the results I expect. My data is in the table below. I also have a date table, and I marked it as a date table. My date slicer is set to all dates (from 5/10/2014 - 9/22/2017), but it doesn't matter what I set it to. I have a measure, Qty This Month which is calculating correctly (or at least what I expect, 37.15):

Qty This Month = TOTALMTD(SUM('Sales'[Quantity]), 'Date'[Date])

What's not working is my measure with PARALLELPERIOD, which I'm using to attempt to get the previous month quantity. 

Prev Month Qty (Parallel Period) = CALCULATE(SUM('Sales'[Quantity]), PARALLELPERIOD('Date'[Date], -1, MONTH))

It returns 448.36, which is the sum of everything except the 37.15 from the current month, and I'm expecting 154.57. I've also tried using DATEADD and PREVIOUSMONTH. The former returns the same as PARALLELPERIOD and the latter returns blank.

It's been a long week, and I'm sure it's something silly, but I'd appreciate any insights. There's a working copy of the file here, named ParallelPeriod.pbix.

CustomerId    Quantity  SaleDate

CUSTOMER217.1210/1/2016
CUSTOMER217.3710/1/2016
CUSTOMER216.9210/1/2016
CUSTOMER218.7312/9/2016
CUSTOMER217.0412/9/2016
CUSTOMER217.5612/9/2016
CUSTOMER218.112/23/2016
CUSTOMER218.5312/23/2016
CUSTOMER216.582/10/2017
CUSTOMER218.052/10/2017
CUSTOMER221.983/17/2017
CUSTOMER217.453/17/2017
CUSTOMER220.786/1/2017
CUSTOMER220.866/1/2017
CUSTOMER218.467/31/2017
CUSTOMER218.268/10/2017
CUSTOMER219.088/10/2017
CUSTOMER219.268/10/2017
CUSTOMER218.388/10/2017
CUSTOMER219.988/18/2017
CUSTOMER219.38/18/2017
CUSTOMER217.888/24/2017
CUSTOMER220.88/24/2017
CUSTOMER219.898/24/2017
CUSTOMER218.049/6/2017
CUSTOMER219.119/7/2017
1 ACCEPTED SOLUTION

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.

 

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

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. Smiley Wink

 

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.