I'm looking to do a rolling average where the user enters x number of years and it averages over those x years over time. The data set looks as follows:

Column A has dates from a to b in descending order (date b is first and date is a is last)
Column B has data that corresponds to each date
Column C should have a rolling average over time. For example if x is set to 1 the first entry should be the average of data points 1 to 365, the second entry should be the average of data points 2 to 366, etc. The problem is, I am unsure of how to get the range that is averaged to changed based on what x is set to. For example if x is set to 2, then it should be averaging data points 1 to 730.

Any formula to help me achieve this would be great. Don't need the formula to be contained within a single column, I am open to using multiple columns to achieve this result.

Many thanks!