if last()=0 then window_sum(sum([Sales]),-4,-1) end is the way I do that here. Check out the examples in this workbook using superstore.
I hope that helps you get going.
Considering how it is December now, the past 4 months would actually be August, September, October, November. Here is a calculated field you can use to filter for those months. You can adjust the interval in the DATEADD function as you see fit.
IF DATETRUNC('month',[Date])>= DATETRUNC('month',DATEADD('month',-4,TODAY()))
AND DATETRUNC('month',[Date]) <= DATETRUNC('month',DATEADD('month',-1,TODAY()))
ELSE 'Don't Keep'