Average Ifs based on column header and column value

chimneytop

New Member
Joined
Aug 13, 2015
Messages
7
I have the table located below. The column headers are standardized but do not always appear in the same location. Sometimes Gender is first, sometimes Salary is second etc. I want to be able to Average the salary column for all class 1 people that have a unique Employee ID. How do I reference standardized column header names that appear in dynamic locations? (essentially I want to do where row 1 says salary, average that column if unique employee id)
Employee ID
Class
Salary
Gender
115489422478
1
50000
M
216577849874
1
75000
F
548786330225
3
25000
M
364789512687
5
50000
F

<tbody>
</tbody>
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
If you are using Excel 2007 use an Excel table and Structured References.


Excel 2010
ABCDEFGHIJ
1Employee IDClassSalaryGenderGenderEmployee IDClassSalary
21.15489E+11150000MM1.15489E+11150000
32.16578E+11175000FF2.16578E+11175000
45.48786E+11325000MM5.48786E+11325000
53.6479E+11550000FF3.6479E+11550000
6
7
86250062500
Sheet1
Cell Formulas
RangeFormula
D8=AVERAGEIF(Table1[Class],1,Table1[Salary])
J8=AVERAGEIF(Table2[Class],1,Table2[Salary])
 
Upvote 0
That option doesn't work. I have a system using pivot tables that does this for me, but my co-workers are afraid of excel. I've made it where they paste an excel file and then select the standard headers. I want that informaiton to then pull to another page without them having to do anything. I'm guessing I can do this somehow with an array and hlookup, I just don't know how.
 
Upvote 0
Here's another way:


Excel 2010
ABCDEFGHI
1Employee IDClassSalaryGenderGenderEmployee IDClassSalary
21.15489E+11150000MM1.2E+11150000
32.16578E+11175000FF2.2E+11175000
45.48786E+11325000MM5.5E+11325000
53.6479E+11550000FF3.6E+11550000
6
7
8
96250062500
Sheet2
Cell Formulas
RangeFormula
D9=AVERAGEIF(INDEX($A$1:$D$5,,MATCH("Class",$A$1:$D$1,0)),1,INDEX($A$1:$D$5,,MATCH("Salary",$A$1:$D$1,0)))
I9=AVERAGEIF(INDEX($F$1:$I$5,,MATCH("Class",$F$1:$I$1,0)),1,INDEX($F$1:$I$5,,MATCH("Salary",$F$1:$I$1,0)))
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,844
Members
449,471
Latest member
lachbee

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