Thank you Gysbert! That works.
Unfortunately the requirements was missunderstod and what we need is now is only the average with in the same quarter. Which means if Jan, Feb and March data is available then the formula should calculate the average of these month and show the same value for each month.
If all months in a specific quarter data is available:
formula calculates same result for each month wich is average of cost for these months.
Jan: (sum of cost for every month in this quarter)/count
Feb: same as Jan
March:Same as Jan
If only we have the first month in a quarter of data available:
formula calculates avg of one month.
If only data for two months the formula needs to calculate same result for these two which is the average of them.
Hope you understand what I mean... I am sure your code can be modified in an easy way...
Best regards and Thanks.