AverageIfs returns #div/0 even when all there are no blanks...why?

wiseone

Board Regular
Joined
Mar 14, 2015
Messages
144
Hi all,

I have the following data:
ABCD
112345Parent10#Div/0
212345AChild55
312345BChild1010
412345CChild2020

<tbody>
</tbody>

I am trying to write a formula for column D which takes the average of the child SKUs, however, I keep getting #Div/0.

Formula in column D:
=IF(B1="Parent",AVERAGEIFS(C:C,A:A,left(A1,5),B:B,"Child"),C1)

All data in Column A is TEXT and must remain so.

Some troubleshooting has shown that the "A:A,Left(A1,5)" criteria is causing the error, but I can't understand why......

Any thoughts on what is going on here and how to fix?

Thanks
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
The reason you're getting the error is because this:

A:A,left(A1,5)

Is being evaluated as:

A:A = "12345"

There are no rows that meet both conditions:

A:A = "12345" *AND* B:B = "Child"
 
Upvote 0
I think I figured this out......
Left (a1,5) is the criteria, and it is not looking at the left 5 charaters of all the cells in A:A so it doesn't find anything that meets the criteria.

One solution is to add a helper column which removes the A/B/Cs. =Left(A1,5).

Does anyone know how to do this without a helper column?
 
Upvote 0
Maybe this array formula**:

=IF(B1="Parent",AVERAGE(IF(LEFT(A2:A4,5)=LEFT(A1,5),IF(B2:B4="Child",C2:C4))),C1)

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

You should avoid using entire columns as range references in array formulas. Use smaller specific ranges.
 
Upvote 0
Or maybe this regular formula
=IF(B1="Parent",AVERAGEIFS(C:C,A:A,LEFT(A1,5)&"*",B:B,"Child"),C1)

M.
 
Upvote 0
=IF(B1="Parent",AVERAGEIFS(C:C,A:A,LEFT(A1,5)&"*",B:B,"Child"),C1) didn't work because of same issue. Target reference A:A is not looking at left 5 characters.

The dataset changes size so do not want to use array formulas or dynamic named ranges (file is already slow, trying to minimize using volatile functions).

Is there any way to do Left(A:A, 5) in a formula which references a range?
 
Upvote 0

Forum statistics

Threads
1,216,109
Messages
6,128,884
Members
449,477
Latest member
panjongshing

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