Divide by Zero error
Hello,
I am using the formula below to return the average value of a column. I chose not to use the standard AVG formula because it was considering blank cells and cells with zeros skewing the true average total. However, the formula below is returning DVIVD BY ZERO. I tried adding IFERROR and got incorrect argument. Where did I go wrong here?
=(SUM({Year_1})) / ((COUNT({Year_1}))  (COUNTIF({Year_1}, 0)))
Thank you,
Best Answers

Hi @LeAndre P
The error indicates that the second half of your formula returns 0. To troubleshoot this, I would try out each COUNT formula separately to see what it returns:
=COUNT({Year_1})
=COUNTIF({Year_1}, 0)
If you're getting the same number, then subtracting one from the other would result in 0, which you cannot divide by. If you shouldn't be getting the same number, can you post a screen capture of your {Year_1} column (but please block out sensitive data).
Thanks!
Genevieve

Hi @LeAndre P
I'm glad you were able to solve it! Just a note... although this should work fine, you don't need quite so many parentheses. It may be easier to troubleshoot down the line if you remove out the extras:
=IF(COUNT({Year_1}) = COUNTIF({Year_1}, 0), 0, SUM({Year_1}) / (COUNT({Year_1})  COUNTIF({Year_1}, 0)))
Cheers,
Genevieve
Answers

Hi @LeAndre P
The error indicates that the second half of your formula returns 0. To troubleshoot this, I would try out each COUNT formula separately to see what it returns:
=COUNT({Year_1})
=COUNTIF({Year_1}, 0)
If you're getting the same number, then subtracting one from the other would result in 0, which you cannot divide by. If you shouldn't be getting the same number, can you post a screen capture of your {Year_1} column (but please block out sensitive data).
Thanks!
Genevieve

Hi Genevieve,
Thank for assisting. I think I managed to solve this one by using the following formula.
=IF((COUNT({Year_1})) = (COUNTIF({Year_1}, 0)), 0, SUM({Year_1}) / ((COUNT({Year_1}))  (COUNTIF({Year_1}, 0))))
Regards,

Hi @LeAndre P
I'm glad you were able to solve it! Just a note... although this should work fine, you don't need quite so many parentheses. It may be easier to troubleshoot down the line if you remove out the extras:
=IF(COUNT({Year_1}) = COUNTIF({Year_1}, 0), 0, SUM({Year_1}) / (COUNT({Year_1})  COUNTIF({Year_1}, 0)))
Cheers,
Genevieve
Help Article Resources
Categories
 All Categories
 14 Welcome to the Community
 10.7K Get Help
 63 Global Discussions
 69 Industry Talk
 385 Announcements
 3.5K Ideas & Feature Requests
 55 Brandfolder
 125 Just for fun
 50 Community Job Board
 464 Show & Tell
 40 Member Spotlight
 44 Power Your Process
 28 Sponsor X
 234 Events
 7.3K Forum Archives
Check out the Formula Handbook template!