Adjust average formula properly when the table is extended

vladimiratanasiu

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

I have a table that shows the electric power data (period, consumption etc.) of a client. At the end of each year, it is calculated the monthly average of consumption and costs. Since 2022, giving the variation of months with / without consumption, it is included also a progressive average, calculated as mean value of the whole period between the first and the last month with non-zero energy. In our example (cell Q68), progressive average is given by the period January 2022 – October 2022, resulting a total of 383 kW/10 months (they are accounted also the zero consumption months). The issue appeared when I added the year 2023 and tried to adjust in the cells Q87 and R87 formulas from cells Q68 and R68, considering the new references (Q74 and R74). Even if I didn’t add yet new values of year 2023, the cells Q87 and R87 show non-zero results. Which is the right solution in this case and how should I adjust it when add a new similar table in the future (2024, 2025 etc.)?

Thank you!

P.S. The XLBB didn't picked up completly data from my table, keeping blank the rows with number of the years. I attach a photo of one section, if necessary to.
Untitled1.png


Book1
PQR
1Electric power
2
3PeriodKwhValue (including VAT)
4Jan-1978.29129.00
5Feb-1970.720.00
6Mar-1971.48125.40
7Apr-1964.4220.40
8May-1966.570.00
9Jun-1964.4277.97
10Jul-1966.570.00
11Aug-1966.5795.14
12Sep-1966.290.00
13Oct-1969.790.00
14Nov-1967.5473.30
15Dec-1969.7961.67
16Annual total822.45582.88
17Monthly average 68.5448.57
20
33Annual total650.31485.50
34Monthly average 54.1940.46
37
50Annual total523.04464.67
51Monthly average 43.5938.72
54
55Jan-2254.0036.57
56Feb-2266.0044.70
57Mar-2278.0053.04
58Apr-2268.0046.25
59May-22-10.00-7.12
60Jun-22
61Jul-22
62Aug-2249.0033.32
63Sep-2227.0018.13
64Oct-2251.0034.62
65Nov-22
66Dec-22
67Annual total383.00259.51
68Monthly average 38.3025.95
6931.9221.63
73
74Jan-23
75Feb-23
76Mar-23
77Apr-23
78May-23
79Jun-23
80Jul-23
81Aug-23
82Sep-23
83Oct-23
84Nov-23
85Dec-23
86Annual total0.000.00
87Monthly average 5.323.60
880.000.00
Sheet1
Cell Formulas
RangeFormula
Q16:R16,Q86:R86,Q67:R67,Q50:R50,Q33:R33Q16=SUM(Q4:Q15)
Q17:R17,Q51:R51,Q34:R34Q17=Q16/COUNTA(Q4:Q15)
Q68:R68Q68=AVERAGE(--Q55:INDEX(Q1:Q66,LOOKUP(99^99,Q1:Q66,ROW(Q1:Q66))))
Q69:R69,Q88:R88Q69=Q67/12
Q87Q87=AVERAGE(--Q74:INDEX($Q$1:Q85,LOOKUP(99^99,$Q$1:Q85,ROW($Q$1:Q85))))
R87R87=AVERAGE(--R74:INDEX($R$1:R85,LOOKUP(99^99,$R$1:R85,ROW($R$1:R85))))
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If you put your data into individual tables next to each other, the job would be much easier.
Book1
ABCDEFG
1
2PeriodKwhValue (including VAT)PeriodKwhValue (including VAT)
301/01/201978.29129.0001/01/202254.0036.57
402/01/201970.720.0002/01/202266.0044.70
503/01/201971.48125.4003/01/202278.0053.04
604/01/201964.4220.4004/01/202268.0046.25
705/01/201966.570.0005/01/2022-10.00-7.12
806/01/201964.4277.9706/01/2022
907/01/201966.570.0007/01/2022
1008/01/201966.5795.1408/01/202249.0033.32
1109/01/201966.290.0009/01/202227.0018.13
1210/01/201969.790.0010/01/202251.0034.62
1311/01/201967.5473.3011/01/2022
1412/01/201969.7961.6712/01/2022
15Annual total822.45582.88Annual total383.00259.51
16Monthly average 68.537548.57Monthly average 47.8832.44
Sheet1
Cell Formulas
RangeFormula
B15,F15B15=SUBTOTAL(109,[Kwh])
C15C15=ROUND(SUBTOTAL(109,[Value (including VAT)]),2)
B16B16=AVERAGE(Table1[Kwh])
C16C16=ROUND(AVERAGE(Table1[Value (including VAT)]),2)
G15G15=SUBTOTAL(109,[Value (including VAT)])
F16F16=AVERAGE(Table2[Kwh])
G16G16=ROUND(AVERAGE(Table2[Value (including VAT)]),2)

I added ROUND to some of the formulas because the column indicated a currency value with VAT in the header, and you'd want that to be accurate.
 
Upvote 0
If you put your data into individual tables next to each other, the job would be much easier.
Book1
ABCDEFG
1
2PeriodKwhValue (including VAT)PeriodKwhValue (including VAT)
301/01/201978.29129.0001/01/202254.0036.57
402/01/201970.720.0002/01/202266.0044.70
503/01/201971.48125.4003/01/202278.0053.04
604/01/201964.4220.4004/01/202268.0046.25
705/01/201966.570.0005/01/2022-10.00-7.12
806/01/201964.4277.9706/01/2022
907/01/201966.570.0007/01/2022
1008/01/201966.5795.1408/01/202249.0033.32
1109/01/201966.290.0009/01/202227.0018.13
1210/01/201969.790.0010/01/202251.0034.62
1311/01/201967.5473.3011/01/2022
1412/01/201969.7961.6712/01/2022
15Annual total822.45582.88Annual total383.00259.51
16Monthly average 68.537548.57Monthly average 47.8832.44
Sheet1
Cell Formulas
RangeFormula
B15,F15B15=SUBTOTAL(109,[Kwh])
C15C15=ROUND(SUBTOTAL(109,[Value (including VAT)]),2)
B16B16=AVERAGE(Table1[Kwh])
C16C16=ROUND(AVERAGE(Table1[Value (including VAT)]),2)
G15G15=SUBTOTAL(109,[Value (including VAT)])
F16F16=AVERAGE(Table2[Kwh])
G16G16=ROUND(AVERAGE(Table2[Value (including VAT)]),2)

I added ROUND to some of the formulas because the column indicated a currency value with VAT in the header, and you'd want that to be accurate.

If you put your data into individual tables next to each other, the job would be much easier.
Book1
ABCDEFG
1
2PeriodKwhValue (including VAT)PeriodKwhValue (including VAT)
301/01/201978.29129.0001/01/202254.0036.57
402/01/201970.720.0002/01/202266.0044.70
503/01/201971.48125.4003/01/202278.0053.04
604/01/201964.4220.4004/01/202268.0046.25
705/01/201966.570.0005/01/2022-10.00-7.12
806/01/201964.4277.9706/01/2022
907/01/201966.570.0007/01/2022
1008/01/201966.5795.1408/01/202249.0033.32
1109/01/201966.290.0009/01/202227.0018.13
1210/01/201969.790.0010/01/202251.0034.62
1311/01/201967.5473.3011/01/2022
1412/01/201969.7961.6712/01/2022
15Annual total822.45582.88Annual total383.00259.51
16Monthly average 68.537548.57Monthly average 47.8832.44
Sheet1
Cell Formulas
RangeFormula
B15,F15B15=SUBTOTAL(109,[Kwh])
C15C15=ROUND(SUBTOTAL(109,[Value (including VAT)]),2)
B16B16=AVERAGE(Table1[Kwh])
C16C16=ROUND(AVERAGE(Table1[Value (including VAT)]),2)
G15G15=SUBTOTAL(109,[Value (including VAT)])
F16F16=AVERAGE(Table2[Kwh])
G16G16=ROUND(AVERAGE(Table2[Value (including VAT)]),2)

I added ROUND to some of the formulas because the column indicated a currency value with VAT in the header, and you'd want that to be accurate.

Thank you for the answer. Unfortunately, the above ranges are parts of a larger table, structured and linked by formulas vertically. So, they can't be splitted and managed separately.
 
Upvote 0
Bet they can. Pull them into Power Query, manipulate them as need, and then load them to tables. You could even do the Totals and Averages in it, although that does get tricky...
 
Upvote 0
Thank you for the answer. Unfortunately, the above ranges are parts of a larger table, structured and linked by formulas vertically. So, they can't be splitted and managed separately.
I belive you, but this is not available in my case. My whole table is larger and structured more complicated, so that Power Query becomes not a very efficient solution.
 
Upvote 0
I was under the impresson power query is best when dealing with large data groups. But, I have no practical experience with large data and conversions of it.
 
Upvote 0
are you asking for the months with zero to be excluded in your average calculations?
 
Upvote 0
Hi,
For your row number, you can test:
SUMPRODUCT(MAX((ROW(A1:A86))*(A1:A86<=TODAY())))
 
Upvote 0
Hi,
For your row number, you can test:
SUMPRODUCT(MAX((ROW(A1:A86))*(A1:A86<=TODAY())))
Thank you for the answer! However, I need an average formula and can't understand how to integrate your solution in it to solve my issue. The final result should be zero and it is different in my case.
Book5.xlsx
ABC
1Energy consumption
2
3PeriodKwhValue (including VAT)
4Jan-1978.29129.00
5Feb-1970.720.00
6Mar-1971.48125.40
7Apr-1964.4220.40
8May-1966.570.00
9Jun-1964.4277.97
10Jul-1966.570.00
11Aug-1966.5795.14
12Sep-1966.290.00
13Oct-1969.790.00
14Nov-1967.5473.30
15Dec-1969.7961.67
16Total annual822.45582.88
17Average power consumption /month68.5448.57
18
19
20
21Jan-2069.790.00
22Feb-2065.29103.61
23Mar-2056.510.00
24Apr-2054.2798.02
25May-2056.080.00
26Jun-2054.2760.51
27Jul-2056.080.00
28Aug-2056.0872.24
29Sep-2055.070.00
30Oct-2057.8471.41
31Nov-2055.970.00
32Dec-2013.0679.71
33Total annual650.31485.50
34Average power consumption /month54.1940.46
35
36
37
38Jan-2167.820.00
39Feb-2161.25104.51
40Mar-2159.190.00
41Apr-2148.36100.60
42May-2149.970.00
43Jun-2148.3679.73
44Jul-2149.970.00
45Aug-2116.1280.09
46Sep-2167.000.00
47Oct-2111.0063.77
48Nov-2144.0035.97
49Dec-210.000.00
50Total annual523.04464.67
51Average power consumption /month43.5938.72
52
53
54
55Jan-2254.0036.57
56Feb-2266.0044.70
57Mar-2278.0053.04
58Apr-2268.0046.25
59May-22-10.00-7.12
60Jun-22
61Jul-22
62Aug-2249.0033.32
63Sep-2227.0018.13
64Oct-2251.0034.62
65Nov-22
66Dec-22
67Total annual383.00259.51
68Average power consumption /month38.3025.95
6931.9221.63
70
71
72
73
74Jan-23
75Feb-23
76Mar-23
77Apr-23
78May-23
79Jun-23
80Jul-23
81Aug-23
82Sep-23
83Oct-23
84Nov-23
85Dec-23
86Total annual0.000.00
87Average power consumption /month74.00
880.000.00
Sheet1
Cell Formulas
RangeFormula
B16:C16,B86:C86,B67:C67,B50:C50,B33:C33B16=SUM(B4:B15)
B17:C17,B51:C51,B34:C34B17=B16/COUNTA(B4:B15)
B68:C68B68=AVERAGE(--B55:INDEX(B1:B66,LOOKUP(99^99,B1:B66,ROW(B1:B66))))
B69:C69,B88:C88B69=B67/12
B87B87=SUMPRODUCT(MAX((ROW(A1:A86))*(A1:A86<=TODAY())))
 
Upvote 0
are you asking for the months with zero to be excluded in your average calculations?
Thank you for response! As I wrote, I need only the zero values / blank cells between first and last non-zero values to be counted.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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