PowerPivot / DAX measure: Best 3 month period of sales

fparadis1970

New Member
Joined
Mar 28, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,
This is my first ever post, so I hope I wont be breaking any rules... Let me know and I will correct.
Here is my problem:
I have to calculate the best 3 month running sales across a year for a specific item and locate which month corresponds to the highest value. To do this I go through 3 measures (Sample data included in image)

1648499357982.png


I have to calculate the best 3 month running sales across a year for a specific item. To do this I go through 3 measures.


1.RUNNING 3M: Calculates for each month the sum the previous 3 month
=CALCULATE(
[SALES];
DATESINPERIOD('Calendar'[Date];max('Calendar'[Date]);-3;MONTH)
)

2. BEST 3M: Calculates which of the periods is the highest across the time period
=CALCULATE(
maxx(all('Calendar');[RUNNING 3M]);
filter(
'Calendar';
'Calendar'[Year] = year(TODAY())
)
)

3. BEST PERIOD: Checks current month in context to see if it matches the BEST 3M Value
=if(maxx('Calendar';[RUNNING 3M])=[BEST 3M];[BEST 3M])

In my exemple data, the Best 3M latched on a value in 2022 where I need it to stay within the contextual year. In this specific scenario, in January 2022, the sum of Nov 21 + Dec 21 + Jan 22 the best 3M is 30. But this should only apply to 2022 whereas the BEST 3M in 2021 should have been Oct 21 + Nov 21 + Dec 21 at 28 units.

I am convinced this will be a basic conceptual mistake I am making, but I cannot seem to understand what I'm doing wrong.

Thanks in advance.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
In your second measure, you only filter for today’s year
 
Upvote 0
You are right, it was a test trying to solve my issue. Unfortunately even without this filtering the results are the same. Basically I can't seem to forec the Running 3M measure to restart when switching the year context.

BEST 3M =maxx(all('Calendar');[RUNNING 3M])

1648557831481.png
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top