Dateadd formula month to date previous period problem

Hi,

I have some probles with measures for for previous period. I created matrix in wich I look at current year from Jan 1st and every day updating data for yesterday (full day). There is first split by week then by date in matrix rows.

For curent year it’s calculated as it should, but when I calculate for example for period 4 years ago it returns wrong Total at the end of matrix.

Subtotals on a week level are fine, but if you see on the bottom there is total up to 31.01.2019 not to 16.01.2019 because I need to have the same period of 4 years ago. But if I choose from date slicer for example 15th instead of 16th (yesterday actualy) it works fine. I need somehow to limit measure to use period 4 years ago until yesterday date.

As you see subtotals for weeks in the Total should return 10.553K (01.01.2019-16.01.2019) but it returns 17.979K (01.01.2019-31.01.2019) and that is for whole january of 2019.

platinum_1-1674021687247

I used following measures:

Sales current year = SUM(DailySales[Sales_CY])

Sales CY - 4 Dateadd = CALCULATE([Sales current year], DATEADD(DATES[Date], -4, YEAR))

I even try with Parallelperiod but it returns whole year, and it is great for some other ideas :slightly_smiling_face:

Sales CY - 4 Parallel period = CALCULATE([Sales current year], PARALLELPERIOD(DATES[Date], -4,YEAR))

I have separate DATES lookup table, in which there are split by weeks (Year & Week), and other splits.

I ran through many topics and searching through web but I couldn’t find solution. Really tried to do it on myself but without any success.

Any help will be appreciate greatly.

Thanks.

Sasha

Hi @sassaboss

I noticed you didn’t provide a PBIX file. Providing one will help users and experts find a solution to your inquiry faster and better.

A perfect initial question includes all of the following:

  • A clear explanation of the problem you are experiencing
  • A mockup of the results you want to achieve
  • Your current work-in-progress PBIX file
  • Your underlying data file (to allow us to go into Power Query if necessary to transform your data and/or data model – often DAX questions really end up being data modeling solutions)

Check out this thread on Tools and Techniques for Providing PBIX Files with Your Forum Questions

Not completing your data may sometimes cause delay in getting an answer.

Hello @sassaboss ,

We notice that no response was received from you on the post above.

We are waiting for your masked demo pbix file and other supporting links and details so other users can help you in your query.

Due to your inactivity, we’ll be tagging this post as Solved.

Should you wish to add your masked demo pbix file and other supporting links and details, you can reopen this thread.

Thank you!