My bad forgot to make the offset dynamic to your selection. So I added a variable to identify the MonthOffset for [Yesterday’s date] to solve that.
Last Month's date =
VAR Yesterday = [Yesterday's date]
VAR Yoffset = LOOKUPVALUE( Dates[MonthOffset], Dates[Date], Yesterday )
VAR LastMonth =
CALCULATE( MAX( Dates[Date] ),
DATEADD( FILTER( DATESMTD( Dates[Date] ), Dates[Date] = Yesterday ), -1, MONTH )
)
VAR LMifBlank =
CALCULATE( MAX( Dates[Date] ),
FILTER( ALL( Dates ),
Dates[MonthOffset] = Yoffset -1
)
)
RETURN
COALESCE( LastMonth, LMifBlank )
.
Know that this could skip or repeat a day in the series. Let me explain:
Say you’ve selected December 1st that’ll be compared to the last day before November 1st meaning October 31st but November 30th will be compared to October 29th. So in the series there is no comparison with October 30th.
On the other hand if you select January 1st that’ll be compared to the last day before December 1st meaning November 30th but December 31st will also be compared to that day (November 30th).
.
Here’s the fully updated solution. eDNA - % Quantity change v2.pbix (66.5 KB)
If this answers your question please mark this post as Solution (first remove solution mark from post #17 via the … ) Thanks!