I think within this particular forum post lies the answer to this one
Check out this formula below
Sales YTD LY demo =
VAR LastSalesDate = MAXX( ALL( Sales[Purchase Date] ), Sales[Purchase Date] )
RETURN
CALCULATE( [Sales YTD],
SAMEPERIODLASTYEAR(
INTERSECT( VALUES( Dates[Date] ), DATESBETWEEN( Dates[Date], BLANK(), LastSalesDate ) ) ) )
Can you try to integrate the technique here into your formula?
Give this a go.
What INTERSECT does it takes one table and compares it to another table (all virtually here).
What this will do it only give you a context for the calculation up to the last date that you want.
See here for how it worked in the forum example
See how you go with this idea.
Chrs