# Avoiding the #div/0! error

#### erniepoe

##### Active Member
Hi all,

I've currently got a formula that is working fine, it finds the average salary of a table based on both job title and job location, but if it returns an error (for instance, user selects a location that doesn't have that job, the formula simply returns the average salary of that job in all locations.

However, since the table to be presented to the end user doesn't have the job title or location selected yet, all of the unfilled cells are returning with the #div/0 error. One easy fix is to just go in and select random drop downs, but is there an easy way to tweak the below formula so that it returns no value unless title and location are selected, at which point the formula would kick in. I just don't like to look at the #div/o, and would prefer to not do so.

Thanks so much,
Ernie

=IFERROR(AVERAGEIFS(Table2[Annual Salary],Table2[Job Title],[@[Job Title]],Table2[Location],[@Location]),SUMIF(Table2[Job Title],[@[Job Title]],Table2[Annual Salary])/COUNTIF(Table2[Job Title],[@[Job Title]]))

### Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
A few options:
You can hide the error with Conditional Formatting.
It's hard to tell where your 0 is coming from exactly in your formula, but you can build an IF in there somewhere to check for 0, basic syntax: =IF(B1,A1/B1,"")
You can possibly build it into your IFERROR, but I'm not quite sure what your formula is doing exactly.

Replies
3
Views
426
Replies
1
Views
328
Replies
3
Views
375
Replies
2
Views
303
Replies
2
Views
204

Threads
1,219,518
Messages
6,148,745
Members
450,832
Latest member
Tyroneb90

### 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

### 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