Find column by header AND filter by another column?

Joined
Jan 17, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm working on a table that references another and returns the number of employees in each of several regions, by year. The source table includes a row for each employee, with a value of '1' in the column for each year they worked:

Destination Table:
YearRegionEmployees
2020a1
2020b2
2021a2
2021b1

Source Table:
EmployeeRegion2020202120222023
111a0111
222a1100
333b1111
444b1000

I'm trying to find a formula to fill the Employees column of the Destination table. How can I search for the correct header in the source table and return the count in that column, after filtering for the correct year?

My first thought was to FILTER() the Source table by the region in column B, but I can't seem to figure out a way to return the correct column based on the year in column A.

I also tried nesting INDEX() and MATCH() to return the correct column for the year, but then I can't run a FILTER().

Is there a way to do this?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi & welcome to MrExcel.
How about
Fluff.xlsm
ABCDEFGHIJ
1EmployeeRegion2020202120222023YearRegionEmployees
2111a01112020a1
3222a11002020b2
4333b11112021a2
5444b10002021b1
Sheet6
Cell Formulas
RangeFormula
J2:J5J2=SUMIFS(INDEX(C:F,,XMATCH(H2,$C$1:$F$1)),B:B,I2)
 
Upvote 1
Solution
Hi & welcome to MrExcel.
How about
Fluff.xlsm
ABCDEFGHIJ
1EmployeeRegion2020202120222023YearRegionEmployees
2111a01112020a1
3222a11002020b2
4333b11112021a2
5444b10002021b1
Sheet6
Cell Formulas
RangeFormula
J2:J5J2=SUMIFS(INDEX(C:F,,XMATCH(H2,$C$1:$F$1)),B:B,I2)
My hero! It works perfectly. Thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

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