SUMIFS using 2 variables in changing columns

vespagtguy

New Member
Joined
Mar 8, 2016
Messages
4
Greetings,

I have a table that is generated by my payroll company. I need to generate some data based upon this table:

EmployeeSalaryLocationDept
aaa350050100
bb4000501100
ccc300050100
ddd400050200
eee500050200
fff3000502100
ggg700050100
hhh1000050100

<tbody>
</tbody>

I want to find the sum of the salaries (column B) for employees in location 50 (Column C), dept 100 (ColumnD).
This is straight forward as I created the following SUMIFS calculation:

=SUMIFS($B$2:$B$9,$C$2:$C$9,"50",$D$2:$D$9,"100") - Works Fantastic!

Now for my dilemma...
the payroll company has moved my columns either by adding or removing columns which changes the cells that I am performing my lookups upon. The values I want to add are no longer in cloumn B, but are now in column C; and so forth. Such as:

EmployeeCheck #SalaryLocationDept
aaa10001350050100
bb100024000501100
ccc10003300050100
ddd10004400050200
eee10005500050200
fff100063000502100
ggg10007700050100
hhh100081000050100

<tbody>
</tbody>


Is there a way that I can perform this type of lookup based upon the column headers, as the text will not change, but the column location may? For example:
=SUMIFS([Salary],[Location],"50",[Dept],"100")

I know it is not as simple as the above. I just cant seem to grasp the multiple column lookup. Not sure if there would need to be a combination of INDEX and MATCH. Perhaps I'm over-thinking? Thanks in advance.

-vespagtguy
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
=SUMIFS([Salary],[Location],"50",[Dept],"100")

I know it is not as simple as the above.
Actually, if you convert the range to a table, then it really IS just that simple.

Highlight the whole range, Click Insert - Table
Check "My table has headers"
Finish.

Now you can use something like
=SUMIFS(TableName[Salary],TableName[Location],"50",TableName[Dept],"100")
 
Upvote 0
try this


Excel 2012
ABCDEFGH
1EmployeeSalaryLocationDeptSalaryLocationDept
2aaa3500501002350050100
3bb4000501100
4ccc300050100
5ddd400050200
6eee500050200
7fff3000502100
8ggg700050100
9hhh1000050100
Sheet9
Cell Formulas
RangeFormula
F2=SUMIFS(B2:B9,INDEX(A2:D9,0,MATCH(G1,A1:D1,0)),G2,INDEX(A2:D9,0,MATCH(H1,A1:D1,0)),H2)
 
Upvote 0
it really IS just that simple.

Jonmo1,

You, my friend, are a GENIUS! I consider myself fairly knowledgeable in Excel, but I never even thought of converting the data to a table. I spent a few hours yesterday going down the wrong path by combining different functions that just did not work. Thank you so much for your prompt and spot-on response! The next time you're in Ft. Lauderdale, I'll buy you a beer...or two...or three. Thanks again.

-vespagtguy
 
Upvote 0
You're welcome.

Many advantages to using tables.
You no longer have to worry about your formulas referring to ranges that expand over time, it's taken care of automatically.
When you add a new record to the table, formulas are automatically filled down.
 
Upvote 0
The spreadsheet contains much more data than just the three columns I was asking for assistance with. Your solution will work for the entire spreadsheet. Our company has over 300 Employees in 5 states. The employees change, the taxes and rates vary, the IRA / 401K change. This is an all encompassing solution. Many thanks.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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