Count if sold multiple products to the same account

IvanYerk

Board Regular
Joined
Aug 26, 2018
Messages
61
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I envision a summary as such:

[TABLE="width: 270"]
<colgroup><col><col span="3"></colgroup><tbody>[TR]
[TD]Seller[/TD]
[TD]GAP[/TD]
[TD]MBP[/TD]
[TD]BOTH[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Veronica[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Diana[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]

Raw data is as follows:

[TABLE="width: 266"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Seller[/TD]
[TD]Account number[/TD]
[TD]Product[/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD]123[/TD]
[TD]GAP[/TD]
[/TR]
[TR]
[TD]Veronica[/TD]
[TD]456[/TD]
[TD]GAP[/TD]
[/TR]
[TR]
[TD]Veronica[/TD]
[TD]456[/TD]
[TD]MBP[/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD]789[/TD]
[TD]MBP[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]987[/TD]
[TD]GAP[/TD]
[/TR]
[TR]
[TD]Veronica[/TD]
[TD]654[/TD]
[TD]MBP[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]321[/TD]
[TD]GAP[/TD]
[/TR]
[TR]
[TD]Diana[/TD]
[TD]657[/TD]
[TD]MBP
[/TD]
[/TR]
</tbody>[/TABLE]


I want it to count products sold by each seller (and account) with a wrinkle.

For example, Veronica would have a count of 1 in the MBP column and 1 in the BOTH column based on the above data because she sold BOTH products to one account (456) and only one product to the other account (654).

Hope this is clear. This board is immensely helpful. Thanks in advance!!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Questions
Could you tell us the expected results for each seller considering the data sample in post 1?

What are the expected results for Veronica considering the two scenarios below?

[TABLE="class: grid"]
<tbody>[TR]
[TD]
SCENARIO 1
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
Seller​
[/TD]
[TD]
Account number​
[/TD]
[TD]
Product​
[/TD]
[/TR]
[TR]
[TD]
Kevin​
[/TD]
[TD]
123​
[/TD]
[TD]
GAP
[/TD]
[/TR]
[TR]
[TD="bgcolor: #FFFF00"]
Veronica​
[/TD]
[TD="bgcolor: #FFFF00"]
456​
[/TD]
[TD="bgcolor: #FFFF00"]
GAP​
[/TD]
[/TR]
[TR]
[TD]
Kevin​
[/TD]
[TD]
789​
[/TD]
[TD]
MBP​
[/TD]
[/TR]
[TR]
[TD]
John​
[/TD]
[TD]
987​
[/TD]
[TD]
GAP​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #FFFF00"]
Veronica​
[/TD]
[TD="bgcolor: #FFFF00"]
654​
[/TD]
[TD="bgcolor: #FFFF00"]
MBP​
[/TD]
[/TR]
[TR]
[TD]
John​
[/TD]
[TD]
321​
[/TD]
[TD]
GAP​
[/TD]
[/TR]
[TR]
[TD]
Diana​
[/TD]
[TD]
657​
[/TD]
[TD]
MBP​
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
SCENARIO 2
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
Seller​
[/TD]
[TD]
Account number​
[/TD]
[TD]
Product​
[/TD]
[/TR]
[TR]
[TD]
Kevin​
[/TD]
[TD]
123​
[/TD]
[TD]
GAP
[/TD]
[/TR]
[TR]
[TD="bgcolor: #FFFF00"]
Veronica​
[/TD]
[TD="bgcolor: #FFFF00"]
456​
[/TD]
[TD="bgcolor: #FFFF00"]
GAP​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #FFFF00"]
Veronica​
[/TD]
[TD="bgcolor: #FFFF00"]
456​
[/TD]
[TD="bgcolor: #FFFF00"]
MBP​
[/TD]
[/TR]
[TR]
[TD]
Kevin​
[/TD]
[TD]
789​
[/TD]
[TD]
MBP
[/TD]
[/TR]
[TR]
[TD]
John​
[/TD]
[TD]
987​
[/TD]
[TD]
GAP​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #FFFF00"]
Veronica​
[/TD]
[TD="bgcolor: #FFFF00"]
654​
[/TD]
[TD="bgcolor: #FFFF00"]
GAP​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #FFFF00"]
Veronica​
[/TD]
[TD="bgcolor: #FFFF00"]
654​
[/TD]
[TD="bgcolor: #FFFF00"]
MBP​
[/TD]
[/TR]
[TR]
[TD]
John​
[/TD]
[TD]
321​
[/TD]
[TD]
GAP​
[/TD]
[/TR]
[TR]
[TD]
Diana​
[/TD]
[TD]
657​
[/TD]
[TD]
MBP​
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


M.
 
Upvote 0
[TABLE="width: 323"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]SCENARIO 1
[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Seller
[/TD]
[TD]GAP
[/TD]
[TD]MBP
[/TD]
[TD]BOTH[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Veronica[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Diana[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0
[/TD]
[/TR]
</tbody>[/TABLE]


[TABLE="width: 290"]
<colgroup><col><col span="3"></colgroup><tbody>[TR]
[TD]SCENARIO 2
[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Seller
[/TD]
[TD]GAP
[/TD]
[TD]MBP
[/TD]
[TD]BOTH[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Veronica[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Diana[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Maybe something like this

[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
A
[/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][td="bgcolor: #DCE6F1"]
E
[/td][td="bgcolor: #DCE6F1"]
F
[/td][td="bgcolor: #DCE6F1"]
G
[/td][td="bgcolor: #DCE6F1"]
H
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td]
Seller​
[/td][td]
GAP​
[/td][td]
MBP​
[/td][td]
BOTH​
[/td][td][/td][td]
Seller​
[/td][td]
Account number​
[/td][td]
Product​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td]
John​
[/td][td]
2​
[/td][td]
0​
[/td][td]
0​
[/td][td][/td][td]
Kevin​
[/td][td]
123​
[/td][td]
GAP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
Veronica​
[/td][td]
0​
[/td][td]
1​
[/td][td]
1​
[/td][td][/td][td]
Veronica​
[/td][td]
456​
[/td][td]
GAP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
Diana​
[/td][td]
0​
[/td][td]
1​
[/td][td]
0​
[/td][td][/td][td]
Veronica​
[/td][td]
456​
[/td][td]
MBP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td]
Kevin​
[/td][td]
1​
[/td][td]
1​
[/td][td]
0​
[/td][td][/td][td]
Kevin​
[/td][td]
789​
[/td][td]
MBP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]
John​
[/td][td]
987​
[/td][td]
GAP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
7
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]
Veronica​
[/td][td]
654​
[/td][td]
MBP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
8
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]
John​
[/td][td]
321​
[/td][td]
GAP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
9
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]
Diana​
[/td][td]
657​
[/td][td]
MBP​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
10
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Array formula in B2 copied down
=SUM(IF($F$2:$F$100=$A2,IF(ISNA(MATCH($G$2:$G$100,IF($F$2:$F$100=$A2,IF($H$2:$H$100=C$1,$G$2:$G$100)),0)),IF($H$2:$H$100=B$1,1))))
Ctrl+Shift+Enter, not just Enter

Array formula in C2 copied down
=SUM(IF($F$2:$F$100=$A2,IF(ISNA(MATCH($G$2:$G$100,IF($F$2:$F$100=$A2,IF($H$2:$H$100=B$1,$G$2:$G$100)),0)),IF($H$2:$H$100=C$1,1))))
Ctrl+Shift+Enter, not just Enter

Array formula in D2 copied down
=SUM(COUNTIFS($F$2:$F$100,$A2,$H$2:$H$100,C$1,$G$2:$G$100,IF($F$2:$F$100=$A2,IF($H$2:$H$100=B$1,$G$2:$G$100))))
Ctrl+Shift+Enter, not just Enter

Hope this helps

M.
 
Upvote 0
Works perfectly. Arrays are my kryptonite, so I greatly appreciate your help!!
 
Upvote 0

Similar threads

Forum statistics

Threads
1,224,820
Messages
6,181,157
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