Share via

How to fix divide by zero error?

Avriel 0 Reputation points
2025-08-15T16:06:54.0333333+00:00

Hi all,

I'm trying to write an if statement that returns 1 if the formula equals zero and avoids the divide by zero error. I'm trying to show a quarterly percentage of event notes submitted divided by events attended. I'm having an issue when the individual attends zero events in a quarter. If the individual attends any events, it should show the result of (event notes submitted/events attended). If the individual attends zero events, it should show 1.

MetricsQuestion

It should take the sum of the top row (# of notes submitted) divided by the sum of the bottom row (#of events attended). Here's as far as I've gotten:

=IF((SUM(C3:E3)/SUM(C4:E4)=0),1,(SUM(C3:E3)/SUM(C4:E4)))

Any help would be much appreciated!

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

3 answers

Sort by: Most helpful
  1. riny 20,870 Reputation points Volunteer Moderator
    2025-08-16T08:40:49.93+00:00

    Why not just use IFERROR?

    =IFERROR(SUM(C3:E3)/SUM(C4:E4),1)

    Was this answer helpful?

    0 comments No comments

  2. Barry Schwarz 5,756 Reputation points
    2025-08-15T16:27:14.87+00:00

    If you want to avoid the divide by 0 error, you need to test the denominator before you perform the division.

    IF(SUM(CE:E4)=0,1,SUM(C3:E3)/SUM(C4:E4)
    

    Why did you code 0.9 for the error case when your text says you want 1?

    Was this answer helpful?


  3. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2025-08-15T16:22:42.99+00:00

    =IF(SUM(C4:E4)=0, 1, (SUM(C3:E3)/SUM(C4:E4)))

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.