Why are you using <= vPriorMonthYear, do you need all years summed together or just the last month? Also, for 201801, the last Month will be in Year 2017. You might want to consider removing the set analysis from Year field because that is contradicting your YearMonth's set analysis.