Calculate dynamic average of monthly costs

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
347
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello!

I have a situation with costs for different services. I need a dynamic formula to calculate the monthly average value, including automatically the new added months but ignoring the annual totals (see formulas from D31, D32, D33).

Thank you!

Book1
ABCD
1YearMonthCosts
22021Jan-2167.82
3Feb-2161.25
4Mar-2159.19
5Apr-2148.36
6May-2149.97
7Jun-2148.36
8Jul-2149.97
9Aug-2116.12
10Sep-2167.00
11Oct-2111.00
12Nov-2144.00
13Dec-210.00
14Total523.04
152022Jan-2254.00
16Feb-2266.00
17Mar-2278.00
18Apr-2268.00
19May-22-10.00
20Jun-220.00
21Jul-220.00
22Aug-2249.00
23Sep-2227.00
24Oct-2251.00
25Nov-220.00
26Dec-220.00
27Total383.00
282023Jan-230.00
29Feb-230.00
30Mar-23106.00
31Apr-2396.0039.57
32May-2346.0039.79
33Jun-23188.0044.73
34Jul-230.00
35Aug-230.00
36Sep-230.00
37Oct-230.00
38Nov-230.00
39Dec-230.00
40Total436.00
Sheet1
Cell Formulas
RangeFormula
D31D31=AVERAGE(C2:C13,C15:C26,C28:C31)
D32D32=AVERAGE(C2:C13,C15:C26,C28:C32)
D33D33=AVERAGE(C2:C13,C15:C26,C28:C33)
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about in D31
Excel Formula:
=AVERAGEIFS(C:C,B:B,"<="&B31)
 
Upvote 0
How about in D31
Excel Formula:
=AVERAGEIFS(C:C,B:B,"<="&B31)
Thank you for response! Your formula is ok, but requests periodical manual adjustments. However, I need it (if possible) to be a single one for all months and extend dynamically the target range, including automatically in calculations the new periods and their corresponding values added in the future. Thank you!
 
Upvote 0
I'm afraid I don't know what you mean. Just drag the formula down & it will give the same values you have shown.
 
Upvote 0
I'm afraid I don't know what you mean. Just drag the formula down & it will give the same values you have shown.
I mean, in this case, it stops calculating the average at cell B31 (April 2023). But when I add new values for the next months (B32, B33 etc.), it doesn't include and process them automatically. I need it to run in this frame, working either in a merged range common for all months, or as a single value that moves down in line with the last value available.

Book1
ABCD
1YearMonthCosts
22021Jan-2167.8239.57
3Feb-2161.25
4Mar-2159.19
5Apr-2148.36
6May-2149.97
7Jun-2148.36
8Jul-2149.97
9Aug-2116.12
10Sep-2167.00
11Oct-2111.00
12Nov-2144.00
13Dec-210.00
14Total523.04
152022Jan-2254.00
16Feb-2266.00
17Mar-2278.00
18Apr-2268.00
19May-22-10.00
20Jun-220.00
21Jul-220.00
22Aug-2249.00
23Sep-2227.00
24Oct-2251.00
25Nov-220.00
26Dec-220.00
27Total383.00
282023Jan-230.00
29Feb-230.00
30Mar-23106.00
31Apr-2396.00
32May-2346.00
33Jun-23188.00
34Jul-2310.00
35Aug-2320.00
36Sep-2330.00
37Oct-2340.00
38Nov-2350.00
39Dec-2360.00
40Total436.00
Sheet1
Cell Formulas
RangeFormula
D2D2=AVERAGEIFS(C:C,B:B,"<="&B31)
 
Upvote 0
If you only want the formula in the last used row then, you will need VBA.
 
Upvote 0
If you only want the formula in the last used row then, you will need VBA.
Ok. However, is it possible in the case of a merged range (as the yellow one from my last table) to be a proper formula that meets the mentioned conditions? Thank you!
 
Upvote 0
Merged cells are an abomination & should be avoided like the plague.
Also you would need to change the size of the merged cells whenever you add more data, so I don't understand the point of doing that.
 
Upvote 0
Merged cells are an abomination & should be avoided like the plague.
Also you would need to change the size of the merged cells whenever you add more data, so I don't understand the point of doing that.
Ok. In these conditions, could you / anyone else help me with a VBA code, to calculate a single dynamic average for all monthly costs, in line with the last value inserted every time in the table?
 
Upvote 0

Forum statistics

Threads
1,223,876
Messages
6,175,123
Members
452,614
Latest member
MRSWIN2709

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top