SUMPRODUCT with Multiple Criteria?

Joined
Oct 29, 2015
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to sum the quantity of workers and the total duration of the shifts for an activity by activity and type of resource. However I keep getting the #SPILL error.

The source data is from a data dump a named range in a table

Essentially =SUMPRODUCT(Cost_Head="Staff")*(Sub_Head="Carpenters")*(Quantity,Duration)

The named ranges are on a different tab and I've checked that the number of rows reconciles which it does.

Any help appreicated.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You are missing some brackets, try
Excel Formula:
=SUMPRODUCT((Cost_Head="Staff")*(Sub_Head="Carpenters")*(Quantity,Duration))
 
Upvote 0
No joy unfortunately. I now get a #VALUE! error. Having checked the Quantities and Durations ranges there is no text in there. However there is text in these ranges for other categories who are not staff - but they are not the subject of this formula hence me thinking I do not need a sumif.
 
Upvote 0
In that case can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Please see below:

Book1
BCDEFGHIJKL
1Cost_HeadSub_HeadQuantityDuration
2StaffCarpenters610StaffCarpenters#VALUE!
3StaffCarpenters45StaffPlumbers#VALUE!
4StaffPlumbers1012StaffPainters#VALUE!
5StaffPlumbers2515StaffFloor Layers#VALUE!
6StaffPainters3520
7StaffFloor Layers425
8StaffFloor Layers25
Sheet1
Cell Formulas
RangeFormula
L2:L5L2=SUMPRODUCT((Cost_Head=J2)*(Sub_Head=K2)*(Quantity,Duration))
Named Ranges
NameRefers ToCells
Cost_Head=Table1[Cost_Head]L2:L5
Duration=Table1[Duration]L2:L5
Quantity=Table1[Quantity]L2:L5
Sub_Head=Table1[Sub_Head]L2:L5
 
Upvote 0
Thanks for that.
How about
Fluff.xlsm
BCDEFGHIJKL
1Cost_HeadSub_HeadQuantityDuration
2StaffCarpenters610StaffCarpenters80
3StaffCarpenters45StaffPlumbers495
4StaffPlumbers1012StaffPainters700
5StaffPlumbers2515StaffFloor Layers110
6StaffPainters3520
7StaffFloor Layers425
8StaffFloor Layers25
Data
Cell Formulas
RangeFormula
L2:L5L2=SUMPRODUCT((Table1[Cost_Head]=J2)*(Table1[Sub_Head]=K2)*Table1[Quantity],Table1[Duration])
 
Upvote 0
Fantastic. Thank you. I did not realise that I had to include the Table Reference at the start - I thought by naming the ranges it would overcome this.

Thanks again.
 
Upvote 0
You can use named ranges, but I just used the structured references as I couldn't be bothered to setup the named ranges. ;)
 
Upvote 0
You can use named ranges, but I just used the structured references as I couldn't be bothered to setup the named ranges. ;)
Just using this formula in the secure desktop I am working on (can't paste directly unfortunately) - the source table is derived from a Power Query collation of a number of tabs. Are there any properties of these types of tables that would prevent this formula working? In the "offline" version it is fine but I get a #VALUE! error in the secure version.
 
Upvote 0
Make sure that PQ is bringing in numbers rather than text.
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,066
Members
449,090
Latest member
fragment

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