harishrathore: April 13, 2023, 4:12pm

Hey folks,
I need some quick help over here. How can I calculate the volume for the previous three months with DAX? So let’s say we’re in March, I need the volume for the last three months (January to March). I’ve been using this DAX formula:

DATESINPERIOD ( ‘Calendar’[Date], LASTDATE ( ‘Calendar’[Date] ), -3, MONTH )

But now, I only want to select March, but get the volume for the last three months (October to December). Can anyone help me crunch these numbers? Basically, I need a 3-month-over-3-month volume comparison. Appreciate it!
Harish Rathore

Harsh: April 14, 2023, 1:41am

Hey @harishrathore,
Thanks for reaching out. To get what you’re asking for, you’ll need to add another Date table to your data model and create an inactive relationship with the original Date table. Here’s a visual of the data model I’m talking about:

Data Model picture

Now, create a measure for the “Total Sales Last 3 Months” and then, create a measure for “Total Sales for Previous Last 3 Months”. Finally, fix the totals of the “Total Sales for Previous Last 3 Months” with another small measure.

Here’s how the final results should look:

Final Results picture

I’m also attaching a PBIX file so you can see it all in action. Hope this helps!

EnterpriseDNA: April 17, 2023, 8:38pm

Great job, @harsh. Thanks for stepping up with a solution.
Hey @harishrathore, did that answer your question? Remember to mark this thread as ‘solved’ if it did!

See also  do ai not have command limits for fleets

adesinamk: April 18, 2023, 8:47pm

Hello @harishrathore,
Thanks for bringing up this question.
And @Harsh,
Thanks for the detailed answer. I’ll be giving this a try since I had a similar question. Thanks again!

EnterpriseDNA: April 20, 2023, 11:31pm

I hope the responses above answered your question, @harishrathore. Remember, if your question has been answered, mark this thread as ‘solved’. If there’s no more activity on this post in the next few days, we’ll tag it as Solved.

harishrathore: April 25, 2023, 6:14am

Thanks a ton @Harsh for the solution. Kudos to you…
Harish Rathore