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)
[TABLE="width: 500"]
<tbody>[TR]
[TD]Employee ID
[/TD]
[TD]Class
[/TD]
[TD]Salary
[/TD]
[TD]Gender
[/TD]
[/TR]
[TR]
[TD]115489422478
[/TD]
[TD]1
[/TD]
[TD]50000
[/TD]
[TD]M
[/TD]
[/TR]
[TR]
[TD]216577849874
[/TD]
[TD]1
[/TD]
[TD]75000
[/TD]
[TD]F
[/TD]
[/TR]
[TR]
[TD]548786330225
[/TD]
[TD]3
[/TD]
[TD]25000
[/TD]
[TD]M
[/TD]
[/TR]
[TR]
[TD]364789512687
[/TD]
[TD]5
[/TD]
[TD]50000
[/TD]
[TD]F
[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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