New Enterprise DNA Initiatives

Calculating value for a prior period

Hello everyone,
I would like to ask for some help resolving a DAX formula on calculating prior period.

I have a date filter based on the daily calendar that is filtering all sales for the period 10 Oct - 20 Oct 2020.
I created a DAX formula for the previous period based on DATEADD.
However, the result for the prior period is for 10 Sep - 20 Sep 2020.
I would like to calculate the sales for the same number of days before the current period.

Any ideas and help are appreciated.

Regards,
Stoyan

@tyankata, try something like this for your prior period formula:

Prior Period by # Days =
VAR StartDate = CALCULATE( FIRSTDATE( Dates[Date] ), ALLSELECTED( Dates[Date] ))
VAR EndDate = CALCULATE( LASTDATE( Dates[Date] ), ALLSELECTED( Dates[Date] ))
VAR NumDays = DATEDIFF(EndDate, StartDate, DAY)+1

RETURN

CALCULATE( [Sales], DATEADD( Dates[Date], NumDays, DAY ))
1 Like

Hi @Heather,
I have tested and this works great.
Thank you for the help!

Regards,
Stoyan

1 Like

Happy to help, just a quick note, with future questions it can be helpful to have a mockup of your report - because some questions will require a view of your table relationships or even how other measures interact with the problem file. :slight_smile: