Solved

Fastest way to get most recent salary

Posted on 2012-03-23
8
278 Views
Last Modified: 2012-03-27
I have a table with records (rows) that contain the following fields (columns):
Employee Name
Salary change
Change date

The table lists a new record for an employee whenever his/her salary changes.

I'm trying to get the salary (e.g. column b) for the most recent (max) date of each employee.  once I have list with only the unique values for the employees, how would I get the salary figure?

I think I would use an array formula, but I'm stuck.
0
Comment
Question by:BBlu
  • 5
  • 3
8 Comments
 

Author Comment

by:BBlu
ID: 37759440
Actually, It's a little more complicated then that.  I need to return several columns from that row with the most recent date, including things like (new) Job Title and manager.  I think I'm on the right track, but am having problems finding the row with the most recent date.

I'm trying a combination of if and max with an array formula:

{=IF('Salary History'!B2:B8=EmployeeName,MAX('Salary History'!H2:H8),"")}

But it's giving me the max value in that date column no matter what.
0
 

Author Comment

by:BBlu
ID: 37759447
Oh, I had the max and if functions backwards.  This works now:
=MAX(IF('Salary History'!A2:A10000=2678,'Salary History'!H2:H10000,""))

Now, unless someone has a better idea, I need to figure out how to return which row this maximum (most recent) date is, so I can obtain the other information needed from other columns on that same row.  I was thinking I'd use the index function for this.
0
 

Author Comment

by:BBlu
ID: 37759470
I think I got it, actually.  I did not even know you could do array formulas that involved both concatenation and match: WOW!

=MATCH(EmployeeName&F3,'Salary History'!B1:B26&'Salary History'!H1:H26,0)
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 37759538
If Salary History worksheet is sorted by date, you can use LOOKUP function to get the most recent value:
=LOOKUP(1E+40,IF('Salary History'!A$2:A$10000=A3,'Salary History'!H$2:H$10000,""))     array-entered

The corresponding name can be returned using VLOOKUP:
=IFERROR(VLOOKUP(A3,'Salary History'!A$2:B$10000,2,FALSE),"")

And the date using another array-entered formula:
=LOOKUP(1E+40,IF('Salary History'!A$2:A$10000=A3,'Salary History'!C$2:C$10000,""))
LastSalaryQ27646630.xlsx
0
 
LVL 81

Expert Comment

by:byundt
ID: 37759541
The LOOKUP approach allows for the possibility that a salary might go down (reduction in hours, for example). It also does not involve a time-consuming concatenation of two constraints.
0
 

Author Comment

by:BBlu
ID: 37760051
Can you explain what the "1E +40" part is?
0
 
LVL 81

Expert Comment

by:byundt
ID: 37760747
The LOOKUP function assumes that the values are sorted in ascending order. If it doesn't find a value bigger than it is looking for, it returns the last value found. So the trick to getting the last value is to look for something bigger than any value found in the lookup range.

My pet large number is 10^40 (a 1 followed by 40 zeros) or 1E+40. This is bigger than any number an accountant would use, even in Germany during post-World War I inflation. Other people use 1E+308, which is the largest number that Excel can swallow.

LOOKUP can also find the last text value. You do that by looking for something that sorts dead last in alphabetical order. My pet string for this purpose is "zzzzz"
0
 

Author Closing Comment

by:BBlu
ID: 37774324
Thanks for the help.  I ultimately used an array formula to get the highest (most recent) date, then pulled the needed columns.  Your approach, however, offered another way of looking at it and I appreciate the lesson.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question