So you have data like this?
Year, Month, Rain
2008, January, 5
2009, January, 10
2011, January, 5
And you want to show that the average for these four years is 5, because the missing year 2010 should count as 0? I think this:
sum(Rain)/(1+max(total Year)-min(total Year))
Edit: Alternatively, fill in the missing data in your data model. This would allow for the much simpler avg(Rain), and should calculate faster.