Combining SUMPRODUCT & COUNTIF with multiple criteria in sigle column

drewberts

Board Regular
Joined
Sep 5, 2013
Messages
177
Office Version
  1. 365
Platform
  1. Windows
I have a table which has a column containing job status (e.g. live, dead, invoiced etc) and a separate column with a job fee and a third column with a Sub Fee.

I have used:-

=SUMPRODUCT(SUMIF(TabJobs[Current Job Status],CHOOSE({1,2,3,4,5},Settings!$A$1,Settings!$A$2,Settings!$A$3,Settings!$A$4,Settings!$A$5),TabJobs[Sub Fee]))

which gives me a total value of all the jobs that have a sub fee which have one of 5 statuses listed on a sheet called Settings.

I want to do the same that returns the number of jobs.

I can see that simply substituting SUMIF for COUNTIF doesn't work as the criteria structure is different for COUNTIF but I can't work out the correct syntax.

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
For COUNTIF you'd remove the ,TabJobs[Sub Fee] part too.
 
Upvote 0
For COUNTIF you'd remove the ,TabJobs[Sub Fee] part too.

Thanks RoryA - I'd tried that but it counts the number in the jobs status column and not the sub fee column. Your suggestion leaves the formula with no reference to the sub fee column which is the one I want to count.
 
Upvote 0
Does the sub fee column match the criteria? I assume not, so am not really clear what you want to count exactly?
 
Last edited:
Upvote 0
My layout is:-

Current Job Status Fee Sub Fee
Raised 1000 100
Invoiced 2000 200
Raised 500 200
Programmed 4500 0
Dead 1500 100

The list of possible job statuses is on a sheet called Settings (theu are used for data validation from a dropdown list when pickeing Current Job Status). I've used the following to give me a sum for the sub fee column for all rows that contain any of the job statuses that are in cells A1 to A5 on the settings sheet.

=SUMPRODUCT(SUMIF(TabJobs[Current Job Status],CHOOSE({1,2,3,4,5},Settings!$A$1,Settings!$A$2,Settings!$A$3,Settings!$A$4,Settings!$A$5),TabJobs[Sub Fee]))

e.g. if the job statuses list was

Raised
On Hold
Requoted
Programmed
Invoiced
Shelved
Dead

then the sum returned would be £500

I want to do the do the same but count the instances in the Sub Fee column rather than sum them based on the same criteria, so the above example would return 3 (I need it to ignore any zero values in the count).

Hope that makes sense
 
Upvote 0
OK, the ignoring 0s was the key missing piece. You need:

=SUMPRODUCT(COUNTIFS(TabJobs[Current Job Status],CHOOSE({1,2,3,4,5},Settings!$A$1,Settings!$A$2,Settings!$A$3,Settings!$A$4,Settings!$A$5),TabJobs[Sub Fee],"<>0"))
 
Upvote 0
Brill thanks RoryA - this works in principle but the count is wrong - couln't work it out at first but it is also counting blanks. Can I exclude zeros AND blanks or does that give me too many criteria?
 
Upvote 0
Do you ever have any negative fees? If not, just change the last criterion to ">0"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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