Sumproduct with multiple text criteria giving an #N/A error (Weighted Average Formula)

marklemachin

New Member
Joined
Mar 23, 2018
Messages
9
[TABLE="width: 165"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]qty[/TD]
[TD]gp[/TD]
[TD]salesperson[/TD]
[TD]sku[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]4%[/TD]
[TD]andrew[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]4%[/TD]
[TD]andrew[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]3%[/TD]
[TD]andrew[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]2%[/TD]
[TD]kyle[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]4%[/TD]
[TD]kyle[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
</tbody>[/TABLE]


I want the weighted average of column 2 in regards to column 1 when column 3 equals andrew and when column 4 does not equal #N/A.

My formula is this: =SUMPRODUCT(--(C2:C6="andrew"),--(D2:D6<>"#N/A"),B2:B6,A2:A6)/SUMPRODUCT(--(C2:C6="andrew"),--(D2:D6<>"#N/A"),A2:A6)

No matter how I twist the formula I get an #N/A error
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Maybe...

=SUMPRODUCT(--(C2:C6="andrew"),--ISNUMBER(D2:D6),B2:B6,A2:A6)/SUMPRODUCT(--(C2:C6="andrew"),--ISNUMBER(D2:D6),A2:A6)

M.
 
Upvote 0
=SUMPRODUCT(--(vlookup!A:A="Andrew Cicisly"),--ISNUMBER(vlookup!C:C),Sales!F:F,Sales!D:D)/SUMPRODUCT(--(vlookup!A:A="Andrew Cicisly"),--ISNUMBER(vlookup!C:C),Sales!D:D)

Where column F is Gross Profit and column D is Qty. The only difference between the example equation that didn't give me an error and this actual equation is that I'm using the whole column instead of just a range. P.S...the columns on both tabs are same length.
 
Upvote 0
The reason you are getting divided by zero error is that SUMPRODUCT(--(vlookup!A:A="Andrew Cicisly"),--ISNUMBER(vlookup!C:C),Sales!D:D) equals zero. That said what are you doing there? Why are you using two different sheets? Ive used countless sumproduct formulas and have never used one that references different sheets in that manner. Are you saying your data is in different sheets but that the rows are connected somehow?
 
Upvote 0
Yes, its a very large workbook with many different vlookups that tell me whether or not a sale of a sku is in a specific sku category. I was able to find the sum of averages for Gross Profit but my boss wants a weighted average instead. This formula below worked for the sum of averages but now I'm having trouble with weighted average.

=IFERROR(AVERAGEIFS(Sales!F:F,vlookup!$A:$A,"Andrew Cicisly",vlookup!$C:$C,"<>"&"#N/A",Sales!F:F,"<>0"),0)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

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