0
votes

I'm struggling to get the same period of last month. I want to compare the current month period, for instance, today is 16June2021 so I want to get the sales from May 1st to May 16th.

I'm using this formula but I get the whole month total:

Prev MTD = calculate(sum(Sales[Sales_Amount]),DATEADD(filter(DATESMTD(Sales[Sale_Date]),Sales[Sale_Date]<=today()),-1,MONTH))

Creating a table with DATEADD(filter(DATESMTD(Sales[Sale_Date]),Sales[Sale_Date]<=today()),-1,MONTH), I also get every day of last month.

Is it mandatory to use a Date Table? Already tried but the results came empty. Is it something regarding my date format? From the import it comes as date/time format.

Thank you very much

1

1 Answers

0
votes

Try with:

Prev MTD = calculate(sum(Sales[Sales_Amount]),filter(ALL(Sales[Sale_Date]),Sales[Sale_Date] >= DATE( YEAR(TODAY()), MONTH(TODAY())-1, 1) && Sales[Sale_Date]<=today()))