Return Value With Multiple Criteria

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
922
Office Version
  1. 365
Hi ,

My current input sheet looks as below:

Book1
BCDEFG
3BranchNameEmployment StatusPrimary BranchHR PositionJob Grade
4New YorkKellyPermanentNew YorkBranch Head3B
5New YorkMichelleContractExecutive1A
6New YorkMichaelPermanentExecutive1A
7BeoumontJohnPermanentBeoumontBranch Head3B
8BeoumontJennyPermanentExecutive2B
9BeoumontJoshPermanentExecutive2B
10BeoumontMariaPermanentExecutive2B
11ChicagoJohnPermanentBranch Head3B
12ChicagoValdezContractExecutive1B
13ChicagoJuarezContractExecutive1A
14NashvilleManuelContractExecutive2B
15NashvilleThomasContractExecutive2A
16NashvilleKellyPermanentBranch Head3B
Sheet1


I need to summarize the headcount in two tables. The first table is as below:

Book1
IJKLMNOP
3BranchTotal Headcount1A1B2A2B3A3B
4New York3
5Beoumont4
6Chicago2
7Nashville2
Sheet1
Cell Formulas
RangeFormula
J4:J7J4=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>I4)),COUNT(FILTER(ROW($C$4:$C$16),($B$4:$B$16=I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))


In the table above, I have managed to utilize the solution provided earlier for column J. The headcount is Nashville is only two because Kelly's primary branch is New York and she will be accounted for in New York and not Nashville. The same will apply for John.

The rest of the columns are job grades for all employees. The job grades should also remove any duplicates. For example, Kelly is job grade 3B and John is also 3B. So job grade 3B should only show 2 which is one for New York and one for Beoumont. I tried modifying the existing formula as below but did not work:

Excel Formula:
=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>I4)),COUNT(FILTER(ROW($C$4:$C$16),($B$4:$B$16=I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))*COUNTIFS(B4:B16,I4,G4:G16,K3)

Is there a way to modify the formula to show the desired value for the job grades?


In the second table, I need to summarize as follows:


Book1
IJKL
10BranchBranch HeadPermanentContract
11New York1
12Beoumont1
13Chicago1
14Nashville1
Sheet1
Cell Formulas
RangeFormula
J11:J14J11=COUNTIFS($B$4:$B$16,I11,$F$4:$F$16,J$10)



The current formula I am using shows incorrect value. For example, I only have two branch heads which is Kelly and John. Therefore the correct value should be one in New York and one in Beoumont. Example , Kelly takes care of both New York and Nashville but her primary branch is New York and therefore should be allocated only in New York. The same should apply for the employment status of contract and permanent. We have only 6 permanent staffs and not 8 as Kelly and John is counted as each one and not double.

Is there a way to modify the existing formula to show the correct value for Branch Head, Permanent and Contract ?

Appreciate all the help.?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about
+Fluff 1.xlsm
ABCDEFGHIJKLMNOP
1
2
3BranchNameEmployment StatusPrimary BranchHR PositionJob GradeBranchTotal Headcount1A1B2A2B3A3B
4New YorkKellyPermanentNew YorkBranch Head3BNew York3200001
5New YorkMichelleContractExecutive1ABeoumont4000301
6New YorkMichaelPermanentExecutive1AChicago2110000
7BeoumontJohnPermanentBeoumontBranch Head3BNashville2001100
8BeoumontJennyPermanentExecutive2B
9BeoumontJoshPermanentExecutive2B
10BeoumontMariaPermanentExecutive2BBranchBranch HeadPermanentContract
11ChicagoJohnPermanentBranch Head3BNew York121
12ChicagoValdezContractExecutive1BBeoumont140
13ChicagoJuarezContractExecutive1AChicago002
14NashvilleManuelContractExecutive2BNashville002
15NashvilleThomasContractExecutive2A
16NashvilleKellyPermanentBranch Head3B
17
Input
Cell Formulas
RangeFormula
J4:J7J4=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>I4)),COUNT(FILTER(ROW($C$4:$C$16),($B$4:$B$16=I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
K4:P7K4=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($G$4:$G$16=K$3)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
J11:J14J11=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($F$4:$F$16=J$10)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
K11:L14K11=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($D$4:$D$16=K$10)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
 
Upvote 0
Another

Pasta1
IJKLMNOP
1BranchTotal Headcount1A1B2A2B3A3B
2New York3200001
3Beoumont4000301
4Chicago2110000
5Nashville2001100
Plan3
Cell Formulas
RangeFormula
J2:J5J2=COUNTIF($B:$B,$I2)-SUMPRODUCT(--($B$2:$B$100=$I2),COUNTIFS($C$2:$C$100,$C$2:$C$100,$E$2:$E$100,"<>"&$I2,$E$2:$E$100,"<>"))
K2:P5K2=COUNTIFS($B:$B,$I2,$G:$G,K$1)-SUMPRODUCT(--($B$2:$B$100=$I2),--($G$2:$G$100=K$1),COUNTIFS($C$2:$C$100,$C$2:$C$100,$E$2:$E$100,"<>"&$I2,$E$2:$E$100,"<>"))


M.
 
Upvote 0
oops

Correction

Pasta1
BCDEFGHIJKLMNOP
3BranchNameEmployment StatusPrimary BranchHR PositionJob GradeBranchTotal Headcount1A1B2A2B3A3B
4New YorkKellyPermanentNew YorkBranch Head3BNew York3200001
5New YorkMichelleContractExecutive1ABeoumont4000301
6New YorkMichaelPermanentExecutive1AChicago2110000
7BeoumontJohnPermanentBeoumontBranch Head3BNashville2001100
8BeoumontJennyPermanentExecutive2B
9BeoumontJoshPermanentExecutive2B
10BeoumontMariaPermanentExecutive2B
11ChicagoJohnPermanentBranch Head3B
12ChicagoValdezContractExecutive1BBranchBranch HeadPermanentContract
13ChicagoJuarezContractExecutive1ANew York121
14NashvilleManuelContractExecutive2BBeoumont140
15NashvilleThomasContractExecutive2AChicago002
16NashvilleKellyPermanentBranch Head3BNashville002
17
Plan3
Cell Formulas
RangeFormula
J4:J7J4=COUNTIF($B:$B,$I4)-SUMPRODUCT(--($B$4:$B$100=$I4),COUNTIFS($C$4:$C$100,$C$4:$C$100,$E$4:$E$100,"<>"&$I4,$E$4:$E$100,"<>"))
K4:P7K4=COUNTIFS($B:$B,$I4,$G:$G,K$3)-SUMPRODUCT(--($B$4:$B$100=$I4),--($G$4:$G$100=K$3),COUNTIFS($C$4:$C$100,$C$4:$C$100,$E$4:$E$100,"<>"&$I4,$E$4:$E$100,"<>"))
J13:J16J13=COUNTIFS($B$4:$B$100,$I13,$F$4:$F$100,J$12)-SUMPRODUCT(--($B$4:$B$100=$I13),--($F$4:$F$100=J$12),COUNTIFS($C$4:$C$100,$C$4:$C$100,$E$4:$E$100,"<>"&$I13,$E$4:$E$100,"<>"))
K13:L16K13=COUNTIFS($B$4:$B$100,$I13,$D$4:$D$100,K$12)-SUMPRODUCT(--($B$4:$B$100=$I13),--($D$4:$D$100=K$12),COUNTIFS($C$4:$C$100,$C$4:$C$100,$E$4:$E$100,"<>"&$I13,$E$4:$E$100,"<>"))


M.
 
Upvote 0
Hi Fluff and Marcelo,

Thank you so much for your valuable time and patience. Both solution worked and have a great day ahead.?
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Hi,

My apologies. I have another criteria as follows:

Book1
BCDEFGHIJKLMNO
3BranchNameEmployment StatusPrimary BranchHR PositionJob GradeBranchTotal Headcount1A1B2A2B3A
4New YorkKellyPermanentNew YorkBranch Head3BNew York320000
5New YorkMichelleContractExecutive1ABeoumont400030
6New YorkMichaelPermanentExecutive1AChicago211000
7BeoumontJohnPermanentBeoumontBranch Head3BNashville200110
8BeoumontJennyPermanentExecutive2B
9BeoumontJoshPermanentExecutive2B
10BeoumontMariaPermanentExecutive2BBranchBranch HeadPermanentContract
11ChicagoJohnPermanentBranch Head3BNew York121
12ChicagoValdezContractExecutive1BBeoumont140
13ChicagoJuarezContractExecutive1AChicago002
14NashvilleManuelContractExecutive2BNashville001
15NashvilleThomasRetiredExecutive2A
16NashvilleKellyPermanentBranch Head3B
Sheet1
Cell Formulas
RangeFormula
J4:J7J4=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>I4)),COUNT(FILTER(ROW($C$4:$C$16),($B$4:$B$16=I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
K4:O7K4=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($G$4:$G$16=K$3)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
J11:J14J11=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($F$4:$F$16=J$10)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
K11:L14K11=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($D$4:$D$16=K$10)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))


I also have the employment status as "Retired". This headcount should not be counted . In cell M7, this headcount is counted in the current solution. Is there a way to modify the formula to exclude retired headcounts ? Appreciate all the help.
 
Upvote 0
How about
Excel Formula:
=LET(p,FILTER($C$4:$C$16,($E$4:$E$16<>"")*($E$4:$E$16<>$I4)),COUNT(FILTER(ROW($C$4:$C$16),($D$4:$D$16<>"retired")*($G$4:$G$16=K$3)*($B$4:$B$16=$I4)*(ISNA(MATCH($C$4:$C$16,p,0))))))
 
Upvote 0
Solution
Hi Fluff,

That worked. Thank you for your patience and valuable time. Have a great day.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,999
Messages
6,122,645
Members
449,093
Latest member
Ahmad123098

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