Count If

glinboy

New Member
Joined
Apr 7, 2021
Messages
7
Office Version
  1. 2016
Hi,
I'm trying to write a formula to count the number of particular stock items available in stores in different states. I've started writing a COUNTIFS formula which using the example below counts the number based on supplier and dept =COUNTIFS(B2:B404,R1,C2:C404,S1,??)
but i'm getting stuck on how to finish the formula because the numbers for each state are in different columns, if that makes sense??!

SupplierDepartmentBrandLineNSWNTQLDSATASVICWA
xxxx
1​
1​
1​
1​
1​
1​
1​
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Looking at it, I would guess that you you want sum rather than count? (A count would tell you have many states have the item, a sum would tell you have many items they have in total).

Because the last part is spread over several columns, you will need sumproduct to do this.
Sum formula
Excel Formula:
=SUMPRODUCT(($B$2:$B$404=$R1)*($C$2:$C$404=$S1),$E$2:$K$404)
Count formula
Excel Formula:
=SUMPRODUCT(($B$2:$B$404=$R1)*($C$2:$C$404=$S1)*($E$2:$K$404<>0))
 
Upvote 0
thanks (again) Jason! yes, you are correct, will need the sum formula, the only issue i can see with the formula above is that i need to sum the stock items for different stores, which are located in different states, so I need to add in my formula a part which says that if the store is located in WA as shown in the example below, it looks up the WA column in the data example shown above?
Manufacturers
StoreNamexxx
WAAlexander Heights?
 
Upvote 0
I believe that this should do it, you might need to adjust it slightly. I've used "WA" instead of a cell reference in order to make it stand out, but either can be used.

=SUMPRODUCT(($B$2:$B$404=$R1)*($C$2:$C$404=$S1)*($E$1:$K$1="WA"),$E$2:$K$404)

You may need to change the comma near the end to an asterisk, I've left the comma to avoid errors if the table includes formula blanks.
AFK for rest of the day, hopefully someone else will check your thread, I'll look at it when I can later.
 
Upvote 0

Forum statistics

Threads
1,215,569
Messages
6,125,600
Members
449,238
Latest member
wcbyers

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