+ Reply to Thread
Results 1 to 29 of 29

Count where end date falls within range, but non-unique records for Vlookup

  1. #1
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Count where end date falls within range, but non-unique records for Vlookup

    Good morning,

    I have a query I am running into some trouble with. Hoping you can assist.

    On the attached table, I am trying to do a sum of the values in column N ++, where the value in column F is falling within a given month. However, if another value in Column A has a matching start date that is end date +1, I do not want it included.

    So from the example table .. Jodie Baker is in Rows 10 and 11. on Row 10 she has an end date of 13/3/10, however also has a start date in a different role of 14/3/10 in row 11, so her figure for row 10 in March should not be included in the sum. Given the end date in row 11 is a dummy date set 90 years in the future, hopefully she will have moved on by then

    Shane Avenell has data in rows 8 and 9. He should not be counted in April, as there is a starting date on 1 May of a new role. However, the end date in Row 9 of July has no matching start date (End date +1), so this indicates it is a finishing date, and should be included in the sum of people leaving in that month.

    The value to be summed is the respective value in the month column, as that indicates an FTE equivalent. A simple count will not return the value we need.

    Hoping this explains in enough detail. I am running into problems trying to differentiate between those values where there is a matching start date at end date +1 for a different role, and those where it is a true end date.

    Thanks in advance
    Darren
    Attached Files Attached Files
    Last edited by rylo; 05-20-2010 at 06:18 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Not entirely sure I follow but for the sake of simplicity (and arguably efficiency) I would suggest you do the following (based on my interpretation of your requirements):

    1 - create a key of name@startdate

    L5: =$A5&"@"&$E5
    copied down

    2 - revise matrix formula to utilise the key in determining whether or not a given record should be discounted

    N5: =AND(N$3>$E5,N$3<$F5)*ISNA(MATCH($A5&"@"&$F5+1,$L$5:$L$24,0))*$D5
    copied across matrix

  3. #3
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Hi Darren

    Not sure I properly understand your requirement ... but attached is an attempt for you to check ...

    HTH
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    JR makes a good point...

    If the data is always sorted first by name and then by start date then my previous approach is guilty of over-engineering and you could perhaps simplify to:

    N5: =AND(N$3>$E5,N$3<$F5,OR($A6<>$A5,$E6<>$F5+1))*$D5
    applied to matrix
    (ie no need for helper key column)

  5. #5
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Good morning all,
    Thank you both for your replies. Hopefully i can clarify the requirements a bit better, as I think both are pretty close to what I need in their own ways.

    DonkeyOte : your last formula is almost what I am after, however it is designed to change the figure in the actaul matrix? is that correct? I have that formula set in my main sheet as it also does some other functions. I pasted values to use for this example.
    What I need is for that figure to remain as it is in the matrix.

    My overall goal is to sum the FTE EQUIV of the people who are leaving in a particular month. Buy leaving I mean they have an end date, and there is no start date on the next row where they have simply changed roles.

    I understand that simply doing a month to month sum of the FTE can also indicate how many have left, however there will also be new people introduced to the sheet in the future as more are recruited, so this eliminates using this option.

    To answer a couple of questions:
    The sheet will always be maintained in sort order of Name.
    A new role (and therefore a new start date for that role) will always be input in the row directly beneath their previous role.

    HTH, and thank you for the input so far.

  6. #6
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Count where end date falls within range, but non-unique records for Vlookup

    For the sake of clarity, what is the amount you expect for January, for example ...

  7. #7
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    from the test data provided, therre would be a result of 4 in July (4 people with an end date of 18/07/10) but no start date the following day.

    there would also be a result of 1 in august (Row 24 has an end date of 31/8/10 and no corresponding start date the day after)

    From the test data provided, this would be the only results.

    If however any row had an end date in January, and no corresponding start date the day after for the same person, it would sum the value in column D for any of those rows.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    OK, so if I've understood (this time) perhaps:

    N27:
    =SUMPRODUCT(--((($A$6:$A$25<>$A$5:$A$24)+($E$6:$E$25<>($F$5:$F$24+1)))>0),--(TEXT($F$5:$F$24,"MMYYYY")=TEXT(N$3,"MMYYYY")),N$5:N$24)
    copied across to Y27

  9. #9
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Thanks so much DonkeyOte

    It worked perfectly in the example sheet.
    I have transposed it into my main sheet (i took the exact data out of the full sheet initially to save space) and adjusted the cell references to the best of my ability, however have come up with a #N/A error and am unable to identify where it may not be able to locate the number.
    If you are able to check it for me that would be great! I didnt want to include the entire sheet simply for size purposes, but feel it may be warranted. (I at least deleted the monthly data through to 2019 to save some space!! lol)

    Sorry to be a Pain. I know about submitting a full example, however thought matching a cell reference was within my ability .. .obviously not!

    Darren
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Hi,

    Congrats to DonkeyOte ...

    You need to adjust Cell N42 to :
    Please Login or Register  to view this content.

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Not quite, it should be:

    =SUMPRODUCT(--((($A$52:$A$338<>$A$51:$A$337)+($E$52:$E$338<>($F$51:$F$337+1)))>0),--(TEXT($F$51:$F$337,"MMYYYY")=TEXT(N$17,"MMYYYY")),N$51:N$337)

    The SUMPRODUCT does the following:

    1a - compare every name in the data set to the prior name - all names must be processed so range A52:A338 is compared to A51:A337
    (note though the ranges are different they share the same dimension of 287x1)

    1b - compare every start date in the data set to the prior end date - per the name all rows must be processed so E52:E338 is compared to F51:F337
    (note though the ranges are different they share the same dimension of 287x1)

    1a output and 1b are added together - ie an OR test.
    If either a) the names are different or b) the start date is not = prior end date + 1 then you know this transaction is a "possible" for inclusion


    2 - compare the month of the end date to the month of the matrix - all transactions are processed thus F51:F337 dates are compared to header.

    3 - identify the FTE apportionment for summation - all rows to be included thus N$51:N$337


    The corrected formula in N42 onwards should generate 0;0;3;2;0;1 etc
    (there seems to be a spike in Jul-10 but I've not the time to verify I'm afraid)

    Post back if you have further problems.

  12. #12
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Thanks so much to both.

    This now works perfectly

    The spike in July is correct as we have a group of fixed term contracts ending at that time.

    Fantastic work ........ I am eternally grateful to you you guys and gals, assisting us mere mortals
    Have a great day, and I hope your easter was tops!

  13. #13
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Good morning,

    Just when I thought it was safe to go back into "Solved" mode, I have had the goalposts moved by my boss

    This works exactly as requested, so thank you very much. I have just been requested to match the attrition to the same dates as the headcount (being 15th of each month).

    I am assuming if I change the last section of the formula containing the date match of MMYYYY, to be greater than or equal to the previous month in row 17, and less than the current month in row 17, this should amend the count to be in line with the headcount rows?

    I am working throught his now, just checking my head is in the right spot? it is post a 4 day weekend after all

    thanks
    Darren

  14. #14
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Have tried the following in N42, however am getting a #Value! error message :

    Please Login or Register  to view this content.
    I am not sure where the values are picking up different formats?

  15. #15
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    current sheet with code in N42 ...

    NB A couple of rows have been added for other minor calculations at Rows 47 and 48, hence the slight reference changes from prior posts.
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Hi,

    Because you have inserted two new rows, your formula in cell N42 should now look like :
    Please Login or Register  to view this content.
    The sign > has been added to account for the latest request ...

    HTH
    Last edited by JeanRage; 04-06-2010 at 02:08 AM.

  17. #17
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Quote Originally Posted by Grimace
    I have just been requested to match the attrition to the same dates as the headcount (being 15th of each month).

    I am assuming if I change the last section of the formula containing the date match of MMYYYY, to be greater than or equal to the previous month in row 17, and less than the current month in row 17, this should amend the count to be in line with the headcount rows?

    I am working throught his now, just checking my head is in the right spot? it is post a 4 day weekend after all

    thanks
    Darren
    Darren, I'm not quite sure your approach is correct given present setup.

    Using your last sample file - consider Row 88 in which we have a leave date of 18th July.

    Presently:

    a) your HC matrix will show a 1 in July and 0 in August
    this no longer reflects the preferred logic - technically speaking the 1 should appear in August also, no ?

    b) given a) it follows that the revised approach in the SUMPRODUCT will ignore the attrition until August - given the matrix does not reflect this (0) the attrition will in essence be ignored.


    It seems then, to me at least, that you must first adjust your HC matrix approach such that the values reflect the new logic
    that is to say there should be a 1 in August as well as July for row 88

    On a final note regards your formula of:

    =SUMPRODUCT(--((($A$54:$A$342<>$A$53:$A$341)+($E$54:$E$342<>($F$53:$F$341+1)))>0),--(AND($F$53:$F$341>=M$17,$F$53:$F$341<N$17)),N$53:N$341)

    In SUMPRODUCTs / Arrays AND tests are conducted by virtue of multiplication (ORs by virtue of addition) - so your formula should have read:

    =SUMPRODUCT(--((($A$54:$A$342<>$A$53:$A$341)+($E$54:$E$342<>($F$53:$F$341+1)))>0),--($F$53:$F$341>=L$17),--($F$53:$F$341<M$17),M$53:M$341)

    but as stated this won't be a viable approach until such time as the source is corrected per the revised logic
    (you should also adjust to cater for the fact the L17 is blank rather than being 15th Dec 2009 else you could overstate Jan 10 attrition)

  18. #18
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Hi DonkeyOte,

    Thanks for the detailed response.
    The methodology we want to employ here is a snapshot at the 15th of each month. Historically this has given us the most accurate data to work with for Resourcing purposes ... in that a snapshot at the start of the month will miss those leaving soon after the snapshot is taken, and leave us under resourced for the rest of the month. I understand this may happen with any date selected on a monthly basis, however the 15th is used in a number of our resourcing processes, so I am aligning my new sheet with those.

    The Headcount is currently set up in this way, however I initially had the attrition working by calendar month. I would like to align the two, so that the attrition count is anything that falls since the 16th of last month, up until the 15th of the current month.

  19. #19
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Darren, I'm not sure if I was as clear as I had hoped to have been or if I'm failing to understand the significance of your response ?

    I understand what you're looking to do. My prior post was merely making the point that IMO you need to first revise your headcount matrix to reflect the 15th logic, presently it does not.

    Using your last file I tried to use Row 88 to highlight this fact.

    The leave date of 18/07/2010 means that per your revised logic the attrition would not be counted until August 2010 yet your formulae in S88/T88 are such that the final headcount value still appears in July rather than August.
    The result of which is that when the attrition is calculated for August and row 88 is identified the resulting headcount value is 0 (T88) - thus in effect the attrition is ignored.

    For ex. you could perhaps use:

    O53:
    =IF(AND(O$52>$E53,O$52<DATE(YEAR($F53),MONTH($F53)+(DAY($F53)>14),16)),$D53,0)
    applied to matrix

    With the above in place and with the earlier SUMPRODUCT in place, ie:

    O42:
    =SUMPRODUCT(--((($A$54:$A$342<>$A$53:$A$341)+($E$54:$E$342<>($F$53:$F$341+1)))>0),--($F$53:$F$341>=DATE(YEAR(O$17),MONTH(O$17)-1,DAY(O$17))),--($F$53:$F$341<O$17),O$53:O$341)
    copied across

    you will get some results... (0,6,2,0,1,25.4 etc...)

  20. #20
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Hi Donkeyote

    I have tried inputting the formula quoted above for o53, and copying throughout the matrix.

    I noticed that it is causing values to show in both rows where there is a role change for a person (eg row 53 and 54 are both the same person, going from part time to full time (which changes their FTE from 0.7 to 1.0).
    Once copied across, both the values of 0.7 and 1.0 are appearing, which in turn throws out the calculation in the summary rows at the top of the sheet, causing the one person to add 1.7 FTE for that month.
    Any suggestions?

  21. #21
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Given the dates involved both precede the 15th of the month - which value should persist - 0.7 in O53 or 1 in O54 ?

  22. #22
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    At the 15th the value in O54 should be the one presented.

    Herein lies my dilemma around having the date of 15th the catalyst for FTE calculations, but the entire month as the Attrition calc. What I would really like to happen is have the attrition Calc represented as up to and including 15th of this month, but 16th or after the previous month. In that way the 2 should align yeah?

  23. #23
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    I will have a think - in reality the current row must check

    a) next row to see if the next row is a "continuation" and if so must subsequently check whether the current row ends prior to the 15th

    b) prior row to see if the current row is itself a "continuation" and if so est. whether start date precedes the 16th of the month

    It should work it will just be a little cumbersome formula wise.

  24. #24
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    I've not done a lot of testing I'm afraid but I wonder if perhaps you could apply:

    M53
    =$D53*(($E53<=M$52)-(IF(AND($A54=$A53,$E54=($F53+1)),$F53,DATE(YEAR($F53),MONTH($F53)+(DAY($F53)>15),15))<M$52))
    across matrix

    does that generate the expected matrix output as you see it ?

  25. #25
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Thanks DonkeyOte,

    That initially appeared to present the Matrix data correctly, however i have identified that if an end date is 16th or greater in the month, it still shows in the following month. eg Row 59 has an end date of 18/07/2010. This should show as a value of 1 in Column S "July" (as the snapshot is taken at 15th of the month), and should not appear in August. However at present it also shows as 1 in column T "August".

    My other challenge now is the attrition side. in other words, to sum all of those values where they dont have a start date in the following row that is end date + 1.

  26. #26
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Quote Originally Posted by Grimace - earlier post
    What I would really like to happen is have the attrition Calc represented as up to and including 15th of this month, but 16th or after the previous month.
    Quote Originally Posted by Grimace - prior post
    i have identified that if an end date is 16th or greater in the month, it still shows in the following month. eg Row 59 has an end date of 18/07/2010. This should show as a value of 1 in Column S "July" (as the snapshot is taken at 15th of the month), and should not appear in August.
    I guess you need to clarify the requirements for my benefit as I confess given the above I'm struggling a little with the underlying logic given it seems inconsistent.

    Thus far my understanding is as follows:

    Quote Originally Posted by D.O
    -- In terms of attrition, where End Date > 15th of month this should be accounted for in the following month

    -- In terms of headcount, given the above, I'm a little hazy... are you saying that day of month is of no consequence ?

    -- In terms of continuity records precedence is given to whichever record is "active" on the 15th of the cross over month
    Perhaps easiest to demo. the logic by means of examples:

    Start 1-Mar-2010 | End 13-Jun-2010

    From the perspective of the 1/0 matrix - you would expect 1's in Mar, Apr, May, however, for my understanding Jun is the key month - is this 1 or 0 ?

    And if the End date were the 18th Jun what then ?

    And, finally, if the Start were 20-Mar-2010 would we have 1 or 0 in Mar ?

    Presumably all of the rules that you apply to the above would be consistent for continuity records with the previously noted exception regards cross over months:

    0.7 | Start 1-Mar-2010 | End 13-Jun-2010
    1.0 | Start 14-Jun-2010 | End 31-Jul-2020

    where precedence for cross over month is given to whichever record is active on the 15th, in this case the 1.0

    Once the logic of the matrix is finalised we can work on creating the attrition calcs - it would seem in retrospect that we can not have the matrix align correctly for both FTE & Attrition - thus the attrition calc. we become slightly convoluted.

  27. #27
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Hi DonkeyOte,

    Yes I think the lines have become a little blurred the further the post has gone ... I have unwittingly contributed to that as well, so I apologize.

    Good idea with the examples. And yes, the two you have are correct.

    Example 1 .. There would be a 1 showing in March, April, May only. Given the end date is before 15 June, and 15th is the snapshot date, it would therefore be a 0 at that date.

    Example 2 ... Whatever the FTE number is as at 15th June is the figure we need to capture .. so in this example the person goes from part time (0.7) to Full time (1.0) on 14th June, so will show as 1.0 on the snapshot date of 15th.

    Regarding the attrition ... shortest answer is any person that showed in last months figures, and does not show in this months at all (working on above logic of 15th) = attrition.
    The difficulty is going to lie in differentiating between someone who has left all together, and someone who has either changed roles or changed from Part Time to Full Time (or Vice versa).

    Where I think i threw a spanner in the works was initially trying to have the attrition based on a calendar month, rather than matching 15th - 15th. This thinking has since been changed and i am wanting to match it to the same model of 15th of the month being the snapshot.

    Thanks so much for your patience and tenacity so far, it is greatly appreciated.

  28. #28
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Based on your prior post I would suggest:

    M53:
    =$D53*AND($E53<=M$52,$F53>=M$52)
    applied across matrix M53:AH341

    Then for the attrition:

    N42:
    =SUMPRODUCT(--(N$53:N$341=0),--(M$53:M$341>0),--((($A$53:$A$341<>$A$54:$A$342)+($F$53:$F$341<>($E$54:$E$342-1)))>0))
    copied across to AH42

  29. #29
    Forum Contributor Grimace's Avatar
    Join Date
    05-04-2009
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2013 and Office 365 Plus
    Posts
    380

    Re: Count where end date falls within range, but non-unique records for Vlookup

    Thank you so much to everyone involved, particularly you DonkeyOte.

    It now works perfectly

+ 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