+ Reply to Thread
Results 1 to 14 of 14

Calculate salary average

  1. #1
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Calculate salary average

    I have a list of people with 10 years of salary history for each (in ten consecutive columns on the spreadsheet). I need to calculate salary average for 5 consecutive highest years within the last 10 years. Please see example. If employee has less than 5 years, then it should just average the years employee has. Some people have breaks in service, for example employee worked 2011, 2010, 2009 and 2005, 2004, 2003. 2008, 2007, 2006 years should be ignored and skipped in calculating the averages to the next. Depending which combination (2011, 2010, 2009, 2005, 2004 or 2010, 2009, 2005, 2004, 2003) has the highest average would be consider.

    Could someone please help me? Example 1.xls

    Thank you.

    P.S. I worked on this project over a month ago, and daddylonglegs provided the formula:
    =IF(COUNT(B2:K2)<5,AVERAGE(B2:K2),MAX(SUBTOTAL(9,OFFSET(B2,0,COLUMN(B2:G2)-COLUMN(B2),1,5))/5))
    However after reviewing and testing over 3000 people, it turned out the formula does not work properly.

  2. #2
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Calculate salary average

    are you open to useing VBA for this problem?

    i took a look at it and i think that is the only way to do it.
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  3. #3
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Calculate salary average

    Have a look at a pivot table, it may solve the issue for you also.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,641

    Re: Calculate salary average

    Try this:
    Please Login or Register  to view this content.
    Confirmed by holding Ctrl-Shift both then hit Enter
    Quang PT

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Calculate salary average

    Try this array formula.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Calculate salary average

    Hi Coreytroy, I am not that advanced and I have never used pivot table.

  7. #7
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Calculate salary average

    Hi DGagnon, I need to use excel format for this project. Thanks.

  8. #8
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Calculate salary average

    Example - New Formulas.xlsThank you Bebo021999 and Kvsrinivasamurthy. It looks both formula didn't quite worked. Please see attached. Maybe once you see the results you could tell why.
    I appreciate your help. Thank you so much.
    Attached Files Attached Files
    Last edited by monid78; 03-23-2013 at 11:06 AM.

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,641

    Re: Calculate salary average

    Hi Monid78,
    Kvsrini's: Average of the 5 largest values
    Mine: Average of 5 values, these are >0, from the left
    As per you said in #1, the years are sorted from newest to oldest, left to right (2011, 2010, 2009 and 2005, 2004, 2003. 2008, 2007, 2006), means B to K column?
    How about #5, there are values from B to K, why you have average from D to H? My formula calculate from B to F.

  10. #10
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Calculate salary average

    What I need is 5 highest consecutive years. If there are break between years, I need to skip the breaks, like they would not exist and still calculate the highest consecutive years. If there are less than 5 years, the average is calculated based on the years available. I always have to consider all 10 years. because it is possible that 2002-2006 are the highest.

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Calculate salary average

    Apologies - I think I misunderstood your requirements a little in your original thread here

    Try this formula for row 2 copied down (doesn't need "array entry")

    =IFERROR(LARGE(IF({0,1,2,3,4}+{9;8;7;6;5}<11,IF(SUBTOTAL(2,OFFSET(B2,0,{0,1,2,3,4},1,{9;8;7;6;5}))=5,SUBTOTAL(1,OFFSET(B2,0,{0,1,2,3,4},1,{9;8;7;6;5})))),1),IFERROR(AVERAGE(B2:K2),""))

    Note that this works specifically for a range of 10 cells - it needs to be adjusted for different sized ranges - it's possible to make it more generic but then the formula becomes a little more complex

    confirmed with CTRL+
    Audere est facere

  12. #12
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Calculate salary average

    Thank you dadylonglegs. It's possible I didn't explain well the requirements the first time. It seems there is a glich in your new formulaExample - New Formulas.xls. The formula doesn't calculate properly when the highest 5 are salaries 6-10. Please see attached. Your first formula worked well, except it counted empty cells as 0 into average.

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Calculate salary average

    Yes, you're right - I thought I ran through all the possibilities but obviously not.......

    I also started getting circular references with that formula so, with a similar approach try this version - I think it works for all scenarios...

    =IF(COUNT(B2:K2)>5,MAX(IF({0,1,2,3,4,5}+{5;6;7;8;9}<11,IF(SUBTOTAL(2,OFFSET(K2,0,-{0,1,2,3,4,5},1,-{5;6;7;8;9}))=5,SUBTOTAL(1,OFFSET(K2,0,-{0,1,2,3,4,5},1,-{5;6;7;8;9}))))),IFERROR(AVERAGE(B2:K2),""))

  14. #14
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Calculate salary average

    Thank you so much. I think it does work well for all scenarios. I greatly appreciate your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1