Complex count and lookup criteria with multiple values - SumProduct???

AgentoUK

New Member
Joined
Sep 14, 2018
Messages
2
Following on from a question I asked a few days ago, I need to calculate the below

I have a control Table, indicating whether each Team should be included in the results

A
B
1
Team
Include
2Team AlphaYes
3Team BravoNo
4
Team Charlie
Yes
5Team DeltaNo

<colgroup><col><col><col></colgroup><tbody>
</tbody>

I then have a register of each user, and wether they were in or not on a particular day

AB
CDEFGE
1
Agent Name
Team
01/01/2018
02/01/201803/01/201804/01/201805/01/2018Total
2JohnTeam Bravo
InIn0
3MaryTeam AlphaInInInIn4
4KateTeam Delta
InInInInIn0
5BrianTeam BravoInInIn0
6MarkTeam AlphaInIn InIn3
7SarahTeam Charlie
InInInInIn5
8Total
22233
9
10Overall Total
12

<colgroup><col><col span="2"><col span="6"></colgroup><tbody>
</tbody>

So I'd like to have a formula to calculate the volume of "In" values (for each row, column and overall) Only for teams where the Team Name in the control table has a value of "Yes" for the Include column.

Can anyone help?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Book1
AB
1TeamInclude
2Team AlphaYes
3Team BravoNo
4Team CharlieYes
5Team DeltaNo
Sheet1



Book1
ABCDEFGH
1Agent NameTeam1/1/20182/1/20183/1/20184/1/20185/1/2018Total
2JohnTeam BravoInIn0
3MaryTeam AlphaInInInIn4
4KateTeam DeltaInInInInIn0
5BrianTeam BravoInInIn0
6MarkTeam AlphaInInInIn4
7SarahTeam CharlieInInInInIn5
8Total22333
9
10Overall Total13
Sheet2
Cell Formulas
RangeFormula
H2=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!B2)*--(Sheet1!$B$2:$B$5="yes"))*COUNTIF(C2:G2,"in")
H3=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!B3)*--(Sheet1!$B$2:$B$5="yes"))*COUNTIF(C3:G3,"in")
H4=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!B4)*--(Sheet1!$B$2:$B$5="yes"))*COUNTIF(C4:G4,"in")
H5=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!B5)*--(Sheet1!$B$2:$B$5="yes"))*COUNTIF(C5:G5,"in")
H6=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!B6)*--(Sheet1!$B$2:$B$5="yes"))*COUNTIF(C6:G6,"in")
H7=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!B7)*--(Sheet1!$B$2:$B$5="yes"))*COUNTIF(C7:G7,"in")
C10=SUM(C8:G8)
C8{=SUMPRODUCT(IFNA(MATCH($B$2:$B$7&"yes"&C2:C7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),-1)-IFNA(MATCH($B$2:$B$7&"yes"&C2:C7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),0)+1)}
D8{=SUMPRODUCT(IFNA(MATCH($B$2:$B$7&"yes"&D2:D7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),-1)-IFNA(MATCH($B$2:$B$7&"yes"&D2:D7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),0)+1)}
E8{=SUMPRODUCT(IFNA(MATCH($B$2:$B$7&"yes"&E2:E7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),-1)-IFNA(MATCH($B$2:$B$7&"yes"&E2:E7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),0)+1)}
F8{=SUMPRODUCT(IFNA(MATCH($B$2:$B$7&"yes"&F2:F7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),-1)-IFNA(MATCH($B$2:$B$7&"yes"&F2:F7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),0)+1)}
G8{=SUMPRODUCT(IFNA(MATCH($B$2:$B$7&"yes"&G2:G7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),-1)-IFNA(MATCH($B$2:$B$7&"yes"&G2:G7,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5&"in",0),0)+1)}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi,

If I understand correctly, another way (a little simpler):


Book1
ABCDEFGH
1TeamInclude
2Team AlphaYes
3Team BravoNo
4Team CharlieYes
5Team DeltaNo
6
7
8Agent NameTeam1/1/20182/1/20183/1/20184/1/20185/1/2018Total
9JohnTeam BravoInIn0
10MaryTeam AlphaInInInIn4
11KateTeam DeltaInInInInIn0
12BrianTeam BravoInInIn0
13MarkTeam AlphaInInInIn4
14SarahTeam CharlieInInInInIn5
15Total22333
16
17Overall Total13
Sheet274
Cell Formulas
RangeFormula
H9=IF(VLOOKUP(B9,A$2:B$5,2,0)="Yes",COUNTIF(C9:G9,"In"),0)
C15=COUNTIFS(C9:C14,"In",$H9:$H14,"<>0")
C17=SUM(C15:G15)


H9 formula copied down to H14
C15 formula copied across to G15
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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