I'm calculating the last 30 days vs the previous 30 days.
These are my measures:
Total Current 30 Days =
CALCULATE(
[Switch Currency],
FILTER(
'Calendar',
'Calendar'[Date] >= TODAY() - 31 &&
'Calendar'[Date] <= TODAY() - 2
)
)
and
Total Previous 30 Days =
CALCULATE(
'Costs Summary Table'[Sum of measures],
FILTER(
'Calendar',
'Calendar'[Date] >= TODAY() - 61 && -- Go back 61 days to cover a full 30-day period before the previous 30 days
'Calendar'[Date] <= TODAY() - 32 -- Go back 32 days to end 31 days ago
)
)
If I put the two on the Area Chart I see this:
And if I check on timeanddate.com they are really 29 days:
But if I overlap them one results in 30 days, the other in 31 days. (note I have removed the Month from the x-axis):
Where am I wrong?
I found a solution:
Total Current Month = CALCULATE(
'Costs Summary Table'[Sum of measures],
FILTER(
'Calendar',
'Calendar'[Date] >= DATE(YEAR(TODAY()), MONTH(TODAY()), 1) &&
'Calendar'[Date] <= TODAY() -2
)
)
And
Total Previous Month =
CALCULATE(
'Costs Summary Table'[Sum of measures],
FILTER(
'Calendar',
'Calendar'[Date] >= DATE(YEAR(TODAY()), MONTH(TODAY()) - 1, 1) &&
'Calendar'[Date] <= DATE(YEAR(TODAY()), MONTH(TODAY()) - 1, DAY(TODAY()-2))
)
)
Now, this will not compare the last 30 days but the MoM:
Special thanks to Davide Bacci