# Prior Period Calculation - Unsolved

Hi Community,

I raised a question previously on prior period calculation. A part of it was solved but i marked it as solved. I need help with my prior period calculation.

I have a timeframe filter and custom date filter. Custom date filter need to be cleared before using.

I want to get the sales for same number of days immediately prior to current period selection. e.g if the current date selection is 20-Feb-2023 thru 28-Feb-2023, then I want my prior period number to be from period 11-Feb-2023 thru 19-Feb-2023.

I am attaching pbix file with the model.

Thanks a lot.

Regards
Grace
eDNA Solution - PriorPeriod_SimplyfiedDates.pbix (22.9 MB)

Bumping this post for more visibility from our experts and users.

@gracejoshi Hello there! I had a similar problem with one of my reports I did at work.

IsLastWeek =
var vLastWeek = CALCULATE(MAX (âDimCalendarâ[SalesWeekEnding]),
FILTER(ALL(âDimCalendarâ), âDimCalendarâ[Date] = MAX(âDimCalendarâ[Date])-6))

RETURN
IF(âDimCalendarâ[SalesWeekEnding] = vLastWeek, âYâ, âNâ)

Then I dropped this in the filter selection in the table and selected Y

But you are wanting Sales to appear, correct?

This is the DAX I inserted into the table. Do the numbers look right?

OPP Sales PW =
VAR CurrentWeek = SELECTEDVALUE(âDimCalendarâ[Weekno] )
VAR CurrentYear = SELECTEDVALUE(âDimCalendarâ[CalendarYear] )
VAR MaxWeekNumber = (CALCULATE( MAX (âDimCalendarâ[Weekno]), ALL(âDimCalendarâ)))

RETURN
SUMX(
FILTER( ALL(âDimCalendarâ),
IF(CurrentWeek = 1,
âDimCalendarâ[Weekno]= MaxWeekNumber && âDimCalendarâ[CalendarYear] = CurrentYear -1,
âDimCalendarâ[Weekno] = CurrentWeek - 1 && âDimCalendarâ[CalendarYear] = CurrentYear )),
[Opp Sales (Units)])

The context was looking for the week number in order for you to find the previous week. So you can see that here in the code.

Paul

1 Like

Hello @gracejoshi

Did the response above from @Paul.Gerber (thank you!) help solve your query?

If not, can you let us know where youâre stuck and what additional assistance you need?

If it did, please mark the answer as the SOLUTION by clicking the three dots beside Reply and then tick the check box beside SOLUTION

Thank you

Do i need to have separate calculation for weekending ? Cant i have one calc which can be rolled up and down for date heirarchy (date, weekday, weekend, month etc) ?

@gracejoshi No. I used what was in your pbix file. I have uploaded it for you to look at.

Due to inactivity, a response on this post has been tagged as âSolutionâ.

If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box.

We request you to kindly take time to answer the Enterprise DNA Forum User Experience Survey,.

We hope youâll give your insights on how we can further improve the Support forum. Thanks!