+ Reply to Thread
Results 1 to 41 of 41

Calculate the highest 5 consecutive year average salary

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

    Calculate the highest 5 consecutive year average salary

    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 in excel Example.xlsfor each (if they have less than 5 years with salary, then it should just average the years the do have).
    Some people have breaks in service (for five years, there is a blank in that entry). These years should be ignored and skipped in calculating the avergaes.
    Could someone please help me? Thank you.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    HI Monid78,

    Try using below formula:-
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    see attached:-
    Attachment 211457

    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

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

    Re: Calculate the highest 5 consecutive year average salary

    Thank you so much. I think I missed telling one thing, it needs to be 5 highest consecutive years within the last 10 years.

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    5 highest consecutive years within the last 10 years
    what if the highest years are not consecutive.. like:-

    30000, 50000, 15000, 20000, 90000, 75000, 10000, 15000,80000,10000

    now which all value (consecutives) you would consider ?

    Regards,
    DILIPandey
    <click on below * if this helps>

  5. #5
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    You mean like this perhaps?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I tried to make it as an array formula but it was too much for me.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculate the highest 5 consecutive year average salary

    Monid, please do not post duplicate threads. I have closed your other thread regarding this question, you may continue on this 1
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: Calculate the highest 5 consecutive year average salary

    90000 75000 10000 15000 80000
    54,000 average

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

    Re: Calculate the highest 5 consecutive year average salary

    Thank you so much Jacc. I think that worked.

  9. #9
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    90000 75000 10000 15000 80000
    54,000 average
    Try using below formula:-

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    see attached:- highest consecutives calculation.xlsx

    Only issue you'll face when there are less than 5 numbers available adjacent to highest number (90,000 in this case)

    Regards,
    DILIPandey
    <click on below * if this helps>

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

    Re: Calculate the highest 5 consecutive year average salary

    I will have quite a few employees who will have less than 5 years. If an employee has worked only two years earning 50,000 and 30,000, his average would be 40,000 in that case. What would you propose?

  11. #11
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    still formula will work, see attached:-


    highest consecutives calculation.xlsx


    Regards,
    DILIPandey
    <click on below * if this helps>

  12. #12
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    still formula will work, see attached:-


    Attachment 211938


    Regards,
    DILIPandey
    <click on below * if this helps>

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

    Re: Calculate the highest 5 consecutive year average salary

    Yes, it does. Thank you so much.

  14. #14
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    cheers

    You are welcome Monid78. Suggest you to mark this thread as [SOLVED]. Thanks.



    Regards,
    DILIPandey
    <click on below * if this helps>

  15. #15
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    I must admit that I'm a bit confused here. You seem to approve both mine and DILIPandey's solutions, yet they are not the same at all.
    I thought the idea was to calculate the average for all possible 5 year periods within the range and the take the maximum of that.
    DILIPandey's solution is calculating the average during a 5 year period, starting with the highest value in the series. If the highest value is the last, then it will include 4 cells outside the data.
    By coincidence, these two different formulas yield the same result in the example given in post 7.

    I may be voted of this planet for arguing when everyone already seems content, but so be it. This seems too much like a missunderstanding.
    What result would you expect from the data series:
    1 1 1 1 1 1 1 1 1 16 ?

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

    Re: Calculate the highest 5 consecutive year average salary

    You are right Jacc. It is misunderstanding. DILIPandey's solution is not working if the highest salary is at the end. I am not proficient is excel formulas at all, obviously. I tried a few examples and by coincidence it worked. Anyway, I would expect average of 4 from this series. Sorry to both of you

  17. #17
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    I also noticed this Jacc and hence mentioned in my previous post #9 :-

    Only issue you'll face when there are less than 5 numbers available adjacent to highest number (90,000 in this case)
    on right side.. off course - missed that


    and thats why we say "Requirement" step in a solution development (SDLC) is equally important


    Regards,
    DILIPandey
    <click on below * if this helps>

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

    Re: Calculate the highest 5 consecutive year average salary

    Is there one formula (or possibly 2-3 separate formulas) that can consider all possible options? I have over 4000 employees that I need to calculate the average for and it might be difficult to go through each entry manually. Your help is greatly appreciated.

  19. #19
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    You need to decide your stand on each possible combinations, one could be :-

    90000,50000,40000,20000,91000,67000,99999,55000

    highest 5 consecutives you want, but what if they are not together ... where to start then ?






    Regards,
    DILIPandey
    <click on below * if this helps>

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

    Re: Calculate the highest 5 consecutive year average salary

    Example.xls
    I have attached an example. The key word is consecutive. You can't jump around between 10 years to find the highest values.

  21. #21
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Calculate the highest 5 consecutive year average salary

    okay.. why your example 1 has 5 figures in each row ?? I dont think this will be your real scenario.


    Regards,
    DILIPandey
    <click on below * if this helps>

  22. #22
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    monid78, does that mean that my formula from post #5 is basically correct?

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

    Re: Calculate the highest 5 consecutive year average salary

    Example 1 is simply one employee with 10 salaries. I wanted to ilustarte which salaries I would consider for my average.

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

    Re: Calculate the highest 5 consecutive year average salary

    Example 3.xlsJacc, going through a few examples, it seems your formula doesn't work if I have 5 or less salary information. See attached.

  25. #25
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    Ok, now it works but it looks terrible.
    dilipandey, do you think you can make this formula more compact? like making it into an arrayformula or something.
    I tried to make it into an arrayformula several times before but I can't get it to work.
    Attached Files Attached Files

  26. #26
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate the highest 5 consecutive year average salary

    Try this version

    =IFERROR(MAX(SUBTOTAL(1,OFFSET(B2,0,COLUMN(B2:G2)-COLUMN(B2),1,5))),AVERAGE(B2:K2))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  27. #27
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    Now we're talkin'! An array formula that is completely incomprehensible.
    Seems to work perfectly, now I'll have to spend the rest of the night decode this thing.

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

    Re: Calculate the highest 5 consecutive year average salary

    Example 3 Jacc.xlsI used your sheet and added a few examples. Can you see why this doesn't work? Thank you Jacc

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

    Re: Calculate the highest 5 consecutive year average salary

    Example 3 daddylonglegs.xlsThansk daddylonglegs. I tested it and a few examples didn't work. Why?

  30. #30
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    The problem is that the formula ignores the empty cells. If the empy cells are filled in with zeros it seems to calculate correctly.

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

    Re: Calculate the highest 5 consecutive year average salary

    The formula should ignore empty cells, otherwise it counts "0" towards the average if there are less than 5 years in data.

  32. #32
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate the highest 5 consecutive year average salary

    So what result do you expect if fewer than 5 cells are filled, e.g. B2:D2 only are filled - do you just average those 3?

    Assuming the answer is yes then try this version

    =IF(COUNT(B2:K2)<5,AVERAGE(B2:K2),MAX(SUBTOTAL(9,OFFSET(B2,0,COLUMN(B2:G2)-COLUMN(B2),1,5))/5))

    confirmed with CTRL+SHIFT+ENTER
    Last edited by daddylonglegs; 02-04-2013 at 06:50 PM.

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

    Re: Calculate the highest 5 consecutive year average salary

    Yes. And sometimes happens that employee comes back after a few years of break. For example employee worked 2012, 2011 and 2005. I would count all three years for the average. To sum up, I am looking for highest-earning 5 consecutive calendar years of employment within the last 10 years. If there are less than 5 years, I average what is available. Hope this make sense. Thank you so much for all help. This is way bigger for me than I thought.

  34. #34
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate the highest 5 consecutive year average salary

    I edited my previous reply to include a formula suggestion - does that work for you?

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

    Re: Calculate the highest 5 consecutive year average salary

    Example 3 daddylonglegs-NEW FORM.xls
    Thank you, but this new formula still doesn't work. Please see attached.

  36. #36
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate the highest 5 consecutive year average salary

    You haven't "array entered" those formulas.

    Put the first formula in row 2 then select the cell with the formula and press F2 key to select formula. Now hold down CTRL and SHIFT keys and at the same time press ENTER. You will see curly braces like { and } appear around the formula in the formula bar and the results should be as expected.....

    Now you can copy the formula down the column

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

    Re: Calculate the highest 5 consecutive year average salary

    Thank you. I think that worked. I greatly appreciate it. I never heard of "array entered". What does this mean?
    Last edited by monid78; 02-05-2013 at 12:51 PM.

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

    Re: Calculate the highest 5 consecutive year average salary

    It turned out the formula daddylonglegs helped me with doesn't work. For the last month I was working on reviewing records for 3000 of our employees. Just recently I have calculated salaries and turned out that the formula doesn't work for all. Please see attached.
    It looks the formula averages salary 1 through 5 with salaries 4 and 5 being at 0. It should ignore empty cells and move on to next salary.
    I would appreciate your help. Thank you. Example 1.xls

  39. #39
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    Old thread but somehow I got entangled in this.

    This UDF seems to work if the latest 5 is either from left or right:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Jacc; 04-08-2013 at 05:22 PM.

  40. #40
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate the highest 5 consecutive year average salary

    FYI Jacc,

    This question was continued here and I eventually managed to suggest a formula which seemed to work.......

  41. #41
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Calculate the highest 5 consecutive year average salary

    In case someone stumbles on this in the future and decides to use it;
    add sum=0 above n=0.

+ 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