+ Reply to Thread
Results 1 to 14 of 14

Finding the value within a date period for each employee

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Finding the value within a date period for each employee

    Hi guys and girls

    I have a data problem that I hope can be fixed with formulas.

    Quick background:
    I received two reports which have employee numbers, positions and agreements. The problem is the agreements have different dates to the positions, which makes it hard for me to vlookup the award on the position.

    Scenario: There are two sheets, "Positions" (has info such as emp number, position and position start date), and "LevelChange" (has info such as emp number, award and agreement start date).

    Problem: The employee agreements need to be paired in with the position dates that they fall in.


    I have thought about a normal vlookup, however this would not ensure the correct agreement is being paired with the right position period. Next i thought about a between statement, except that's a bit above my skill level.

    I have attached a book that demonstrates the two sheets of data and an additional sheet would would show examples of desired results

    Hope someone has a solution!

    Thanks
    D
    Attached Files Attached Files

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.85 for Mac MS 365
    Posts
    8,515

    Re: Finding the value within a date period for each employee

    I have one that is close to it but I can't reconcile a couple, for one 20004 doesn't start until 6/3/2012 in positions but your earliest in level change is 6/2/2009 so writing a between statement for what is in column C and column D returns an #N/A because 6/2/2009 isn't between 6/3/2012 and 12/31/9999. There are others like that, for example emp number 20006
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    I'd love to hear your solution!
    The NA you refer to might be genuine which means the agreement data doesn't exist for the position date range.

    I'm keen to try whatever you have.

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.85 for Mac MS 365
    Posts
    8,515

    Re: Finding the value within a date period for each employee

    this appears to work,
    =IFERROR(INDEX(LevelChange!$B$3:$B$17,AGGREGATE(15,6,ROWS($1:1)/(LevelChange!$A$3:$A$18=A2)/(LevelChange!$C$3:$C$18>=C2)/(LevelChange!$C$3:$C$18<=D2),COLUMNS(H:H))),"")
    don't ask me how it works, I know some parts but just played with it until I got the whole thing working.

    the columns part can be changed to any column but only the same, for example COLUMNS(A:A) will work too.

  5. #5
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    Awesome! I'll try it on the real data when I'm at work in an hour.
    Will advise of outcome.

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    Hi again, I'm not sure what Column H in the formula references to, as my data test sheets don't use that column

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.85 for Mac MS 365
    Posts
    8,515

    Re: Finding the value within a date period for each employee

    It’s necessary for the formula to work but doesn’t need to reference any active cells, as I noted in post #4 you can reference any column, A:A or B:B, it is returning 1.

  8. #8
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    Unfortunately I'm not sure it's work... I'll upload some of the actual data

  9. #9
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    Heres a sample of the data.
    For the yellow cols E,F and G there needs to be showing the relevant values from the LevelChange sheet within the position date ranges. Hope this makes sense
    Attached Files Attached Files

  10. #10
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.85 for Mac MS 365
    Posts
    8,515

    Re: Finding the value within a date period for each employee

    A reason it will not work is because your Date Start and Date End in LevelChange are NOT real dates. if you can convert them to dates so excel recognizes them as dates then the formula should work with just some adjustments to columns and ranges. You can test if they are dates by putting =ISNUMBER(E2) and same for F2 in level change, both will return FALSE, now if you put the same in the position tab and point to either C2 or D2 it will return TRUE showing the "dates" in that tab are dates (which are merely numbers formatted to look like dates).

  11. #11
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    Hi again,

    Im still sure it doesn't work properly.... I changed the return value from column B to A in the formula and for a few rows it shows the incorrect employee number... still stuck on this 😢

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,760

    Re: Finding the value within a date period for each employee

    Please attach the latest version of the sheet showing the errors AND the expected results (manually mocked up).
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  13. #13
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Finding the value within a date period for each employee

    Hi!

    Attached is the latest data, which has two sheets, one being Position and the other LevelChange.

    The idea is to use vba or an excel formula to fill in the yellow on the Positions sheet to match the employee number and be in the date range of the LevelChange sheet.

    I have filled in the first 9 rows to illustrate the desired results.
    Attached Files Attached Files

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,750

    Re: Finding the value within a date period for each employee

    The formula that I have is similar to Sam's:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The formula returns the same results as in the 9 rows that were manually filled.
    I am assuming that the start date on the LevelChange sheet needs to occur on or before the start date on the Position sheet, since the start dates are all that are mentioned in post #1.
    If that is an incorrect assumption then please explain how you made the decisions when you were filling the values manually, as those would be the same "decisions" the formula should make.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Finding the maximum date for every Employee ID
    By chandramouliarun in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-19-2016, 02:06 PM
  2. [SOLVED] Finding highest/lowest values over a set date period
    By Terry-J in forum Excel General
    Replies: 5
    Last Post: 09-29-2016, 03:31 PM
  3. Sum if Employee has more than one record for period...
    By wrightyrx7 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2014, 07:56 AM
  4. [SOLVED] Semi Monthly autofill Period Starting Date based on Period Ending Date
    By greatwent in forum Excel General
    Replies: 6
    Last Post: 01-30-2014, 03:29 AM
  5. Replies: 0
    Last Post: 07-25-2013, 10:03 AM
  6. Replies: 9
    Last Post: 09-03-2011, 06:24 PM
  7. Charting Employee name and product value over a given period
    By stephen1000 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 12-11-2008, 06:38 PM

Tags for this Thread

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