Counting one column if one of two other columns have a value

xryanx

Board Regular
Joined
Jul 30, 2015
Messages
61
A21:A30 are locations
C32:C2000 has names of locations
G32:G2000 has a dollar amount
H32:H2000 has a dollar amount

I need B21 to only count locations in C32:C2000 that correspond to A21 and have a value in either G21 or H21.

Example C32 is "Home". The formula sees that A21 is "Home", but also looks at G32 and H32 to see if either of them have a value. If so, then 1 is added to B21. If G32 and H32 are both blank, no count is added to B21.

Below is a graph. It show location "308" having 2, but should only show 1.


ABCDEFGH
21Home2$105.00
223082$40.00
23328
24355
25430
26512
27NEL
28LV
29AA
30FQL
31
321/1123HomeJohn Doe1$40.00
331/1124HomeJane Doe2 $65.00
341/2125308Doe John 3$40.00
351/3126308Doe Jane4

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 49px;"><col style="width: 49px;"><col style="width: 49px;"><col style="width: 49px;"><col style="width: 49px;"><col style="width: 49px;"><col style="width: 49px;"><col style="width: 49px;"></colgroup><tbody>
</tbody>
 

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.
xryanx, Good afternoon.

Try to do:

B21 --> =SUMPRODUCT(($C$32:$C$35=A21) * (($G$32:$G$35>0)+($H$32:$H$35>0)))

C21 --> =SUMPRODUCT(($C$32:$C$35=A21) * (($G$32:$G$35)+($H$32:$H$35)))

Please, tell us if it worked as you want.
I hope it helps.
 
Upvote 0
The formula for B21...

Code:
=SUMPRODUCT(($C$32:$C$2000=A21)*(($F$32:$F$2000>0)+$G$32:$G$2000>0))

And C32...

Code:
=SUMPRODUCT(($C$32:$C$2000=A21)*(($F$32:$F$2000>0)+$G$32:$G$2000>0)*$F$32:$G$2000)
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

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