Hi,
This will work as long as there is only data from the last 12 months and there is no overlapping of years.
A starting month of November or December may cause an overlap between years. Test the formula with those months to be sure. You may have to include a year when you group as well to deal with this.
Good luck,
Brian