=AVERAGE() vs avoiding empty cells

msword

New Member
Joined
Oct 23, 2020
Messages
46
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
I am creating the "currency exchange" sheet for 2023. The problem is that I am getting the "#DIV/O!" error for future monthes (e.g. December) or any empty monthes in the past (e.g. January). Therefore, the =AVERAGE() exchange rate for the whole year 2023 is also became broken with the "#DIV/O!" error automatically.
The solution to that might be to avoid empty cells during =AVERAGE() calculation, but how to achieve that?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I am creating the "currency exchange" sheet for 2023. The problem is that I am getting the "#DIV/O!" error for future monthes (e.g. December) or any empty monthes in the past (e.g. January). Therefore, the =AVERAGE() exchange rate for the whole year 2023 is also became broken with the "#DIV/O!" error automatically.
The solution to that might be to avoid empty cells during =AVERAGE() calculation, but how to achieve that?
You can use =AGGREGATE instead. =AGGREGATE(1,6,range)

The 1 declares the AVARAGE function and the 6 ignores error values within the range.
 
Upvote 0
You can use =AGGREGATE instead. =AGGREGATE(1,6,range)

The 1 declares the AVARAGE function and the 6 ignores error values within the range.
The same "#DIV/O!" error is produced after applying =AGGREGATE(1,6,M26:M31)
 
Upvote 0
The same "#DIV/O!" error is produced after applying =AGGREGATE(1,6,M26:M31)
Could you provide a sample of your data then and the formula producing the error? I tested my suggestion by forcing a #DIV/0! error and it worked as expected.
 
Upvote 0
Have you tried to exclude the zeros in the average calculation by using AVERAGEIF

Code:
=AVERAGEIF(A1:A10,"<>0")
 
Upvote 0
Have you tried to exclude the zeros in the average calculation by using AVERAGEIF

Code:
=AVERAGEIF(A1:A10,"<>0")
I believe the issue is the #DIV/0! error resulting from underlying formulas within the Average range are causing the Average function to also return an error, which AverageIf also falls victim to. Not sure why the Aggregate function is not working for them.
 
Upvote 0
1. You can add IFERROR to the monthly average formula:

=IFERROR(AVERAGE(...),"")

2. Or use the annual average formula:

=AVERAGE(IF(ISNUMBER(Range),Range,""))
 
Upvote 0
Have you tried to exclude the zeros in the average calculation by using AVERAGEIF

Code:
=AVERAGEIF(A1:A10,"<>0")
Same #DIV/O! error.
I believe the issue is the #DIV/0! error resulting from underlying formulas within the Average range are causing the Average function to also return an error, which AverageIf also falls victim to. Not sure why the Aggregate function is not working for them.
=AGGREGATE(1,6,M26:M31)
All cell in M26:M31 in the beyond example are empty. No values. No formulas.

1. You can add IFERROR to the monthly average formula:

=IFERROR(AVERAGE(...),"")
Its just filling the cell with what i put in between the double quotes (e.g. "1"). I don't understand how it could help.

2. Or use the annual average formula:

=AVERAGE(IF(ISNUMBER(Range),Range,""))
ISNUMBER has 2 ranges and a quotes. why? I have only single month/range. breaks my noobie excel mind.

here is my example:
example.xlsx
BCDEF
2averages
3$
42023#DIV/0!#DIV/0!
5
6JAN39.62
7FEB#DIV/0!
8MAR#DIV/0!
9APR#DIV/0!
10MAY#DIV/0!
11JUN#DIV/0!
12JUL#DIV/0!
13AUG41.5
14SEP#DIV/0!
15OCT#DIV/0!
16NOV#DIV/0!
17DEC#DIV/0!
18
19rates €
20JAN39.539.3540
21FEB
22MAR
23APR
24MAY
25JUN
26JUL
27AUG4142
28SEP
29OCT
30NOV
31DEC
Sheet1
Cell Formulas
RangeFormula
C4:D4C4=AVERAGE(C6:C17)
C6:C17C6=AVERAGE(C20:F20)
 
Upvote 0
Aggregate works fine for me in C4, D4 amended for no numbers in the range.

Book1.xlsb
ABCDEF
1
2averages
3$
4202340.5583333 
5
6JAN39.61666667
7FEB#DIV/0!
8MAR#DIV/0!
9APR#DIV/0!
10MAY#DIV/0!
11JUN#DIV/0!
12JUL#DIV/0!
13AUG41.5
14SEP#DIV/0!
15OCT#DIV/0!
16NOV#DIV/0!
17DEC#DIV/0!
18
19rates €
20JAN39.539.3540
21FEB
22MAR
23APR
24MAY
25JUN
26JUL
27AUG4142
28SEP
29OCT
30NOV
31DEC
Sheet1
Cell Formulas
RangeFormula
C4C4=AGGREGATE(1,6,C6:C17)
D4D4=IF(SUM(D6:D17)=0,"",AGGREGATE(1,6,D6:D17))
C6:C17C6=AVERAGE(C20:F20)
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,068
Members
449,091
Latest member
remmuS24

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