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:
I'm sorry, I do not understand what your requirement is.

I was under the impression you wanted averages or counts for the 12 months in each yearly section.
If that is the case the only thing I want to know is if you want to include months with blank/zero amounts in the denominator.
I mentioned that the issue pointed the progressive average, since 2023 (see in my last table cells B87 and C87). I started to use it in 2022 (cells B68 and C68). The result is calculated as mean value of the whole period between the first and the last month with non-zero energy, considering also the non-value / zero value cells from that range as counting cells. In my last table they are ranges B55:B64 / C55:C64 (year 2022) - 10 valid months, and B74:B76 / C74:C76 (year 2023) - 3 valid months. If they are added other new values in the next cells, the average should automatically cover them, too.
 
Last edited:
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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.View attachment 82846

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))))
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.View attachment 82846

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))))
I posted this message two weeks ago, but didn't get a proper solution until now. Could you see the answers given and tell me how to overcome this issue? Thank you!
 
Upvote 0
Well, I don't really understand the requirement as you have written them.
This is my impression:
1 You want a yearly average and sum of energy consumption.
2. The average is to exclude months with no consumption reported.

What other requirement(s) am I missing?
 
Upvote 0
Well, I don't really understand the requirement as you have written them.
This is my impression:
1 You want a yearly average and sum of energy consumption.
2. The average is to exclude months with no consumption reported.

What other requirement(s) am I missing?
1. I need an average formula, to take into consideration years starting with 2023. There is already a previous sollution of this issue, available for the year 2022 (see in the last table, cells P68 and Q68), working fine only in that year. When I adjusted it in 2023 (when is no specific consumption values recorded yet), it generates errors (see in the same table, the results from cells P87 and Q87). 2. I wrote to you in a previous answer that "the average formula should address the range between the first non-zero to the last non-zero cells, covering them and those blank / with zero values too, from that range. This fact was pointed also in the results of my initial formulas (383/10 months - they are counted also those without values = 38,3). If you notice, in my original table there are the cells B69 and C69. They have formulas, shown under the table, that divide the total to 12 months with clear results, but are totally distinct from the yellow ones that I am interested for (B87, C87 vs. B68, C68)."
 
Upvote 0
Vladimir, i have already written that I did not understand your requirment the way you have repeated.
But, here is another attempt:
WorkBook1.xlsx
PQRS
89
90Vladimir's Requested Average: Looks fr Row4 to Row85.63.9710526360.67929
91
Sheet1
Cell Formulas
RangeFormula
Q90Q90=SUM(IFERROR(((--ISNUMBER($P$4:$P$85)*($Q$4:$Q$85))>0)*($Q$4:$Q$85),0)) / SUM(--(IFERROR(--ISNUMBER($P$4:$P$85)*($Q$4:$Q$85),0)>0))
R90R90=SUM(IFERROR(((--ISNUMBER($P$4:$P$85)*($R$4:$R$85))>0)*($R$4:$R$85),0)) / SUM(--(IFERROR(--ISNUMBER($P$4:$P$85)*($R$4:$R$85),0)>0))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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