+ Reply to Thread
Results 1 to 9 of 9

Select dates when first and last occurrence of a value below date row occurs

  1. #1
    Registered User
    Join Date
    04-17-2020
    Location
    Texas
    MS-Off Ver
    365 Pro Plus
    Posts
    13

    Select dates when first and last occurrence of a value below date row occurs

    I need help with two things.

    I have a set of daily work duties showing a day off work as "24" and a day of work as a blank cell. I need to identify the first and last date that each set of work days occurs, for each worker, for each set of work days in the month.

    Second, a list of dates that are days off. The days off and work days are different for each person.

    Below I've shown how the work days are listed, just days of the month with 24 as a work free day, and a blank cell as a day of work.

    I need the output in the format as shown in rows 5 through 26 of the below spreadsheet
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Select dates when first and last occurrence of a value below date row occurs

    Please try at
    B7
    =CHOOSE({1,2},TRANSPOSE(FILTER($B$1:$AE$1,(INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)="")*(INDEX($A$2:$AD$3,MATCH(B$5,$A$2:$A$3,),)<>""))),TRANSPOSE(FILTER($B$1:$AE$1,(INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)="")*((INDEX($C$2:$AF$3,MATCH(B$5,$A$2:$A$3,),)<>"")+($C$1:$AF$1="")))))

    B11
    =TRANSPOSE(FILTER($B$1:$AE$1,INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)))
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-17-2020
    Location
    Texas
    MS-Off Ver
    365 Pro Plus
    Posts
    13

    Re: Select dates when first and last occurrence of a value below date row occurs

    Bo_Ry,

    Greatly appreciated.

    Works great in cells B7 and B11. Modified B7 slightly for C7: CHOOSE(1,2) to CHOOSE(2,2) in cell C7 to get proper end date for C7 and copied B7:C7 to D7:E7 and works correctly there (thanks for the reference to B5)

    Also B11 works correctly, and does correctly in D11 when pasted there.

    Where I am stuck is B8 and B12. Any idea how I can modify to get the next set of work days? B8 should return 14 JUN and B12 should return 2 JUN.

    The trick with B8 - B10 is to ignore the previously selected work blocks and go to the next. Same concept with B11 and below, I need it to ignore previous 24's and just go to the next date where a "24" occurs.

    Any suggestions?

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Select dates when first and last occurrence of a value below date row occurs

    Please check the file upload in Post #2

    This is dynamic array Office 365, the formula in B7 spill to cover B7:C10
    No need to copy formula to C7 or B8:C10

    C10 font color in formula bar is gray out, because of no formula there.

    Dynamic.jpg

  5. #5
    Registered User
    Join Date
    04-17-2020
    Location
    Texas
    MS-Off Ver
    365 Pro Plus
    Posts
    13

    Re: Select dates when first and last occurrence of a value below date row occurs

    Might help if i use my Excel 365 not the old one on my MAC. I'll report back!

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Select dates when first and last occurrence of a value below date row occurs

    Here' s the formula for older version

    B7
    =IFERROR(AGGREGATE(15,6,$B$1:$AE$1/(INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)="")/(INDEX($A$2:$AD$3,MATCH(B$5,$A$2:$A$3,),)<>""),ROWS(B$7:B7)),"")

    C7
    =IFERROR(AGGREGATE(15,6,$B$1:$AE$1/(INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)="")/((INDEX($C$2:$AF$3,MATCH(B$5,$A$2:$A$3,),)<>"")+($C$1:$AF$1="")),ROWS(B$7:B7)),"")

    B11
    =IFERROR(AGGREGATE(15,6,$B$1:$AE$1/(INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)=24),ROWS(B$11:B11)),"")
    Attached Files Attached Files

  7. #7
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Select dates when first and last occurrence of a value below date row occurs

    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Select dates when first and last occurrence of a value below date row occurs

    New formula at
    B7:E10
    =IFERROR(AGGREGATE(15,6,$B$1:$AE$1/($A$2:$A$3=LOOKUP("z",$B$5:B$5))/($B$2:$AE$3=0)/(($A$2:$AD$3>0)+($C$2:$AF$3>0)+($C$1:$AF$1=0)),ROWS(B$7:B7)*2-MOD(COLUMNS($B7:B7),2)),"")


    or 365 Dynamic array
    =AGGREGATE(15,6,$B$1:$AE$1/(INDEX($B$2:$AE$3,MATCH(B$5,$A$2:$A$3,),)=0)/((INDEX($A$2:$AD$3,MATCH(B$5,$A$2:$A$3,),)>0)+(INDEX($C$2:$AF$3,MATCH(B$5,$A$2:$A$3,),)>0)+($C$1:$AF$1=0)),SEQUENCE(4,2))
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-17-2020
    Location
    Texas
    MS-Off Ver
    365 Pro Plus
    Posts
    13

    Re: Select dates when first and last occurrence of a value below date row occurs

    All that now works great so consider it solved! My initial problem was I'm not an "insider" so i was having some issues on my PC with 365. No spill allowed unless I do that. Became an insider on the MAC, updated the app and all good now with all forms of the equation. Last two work on the PC.

    Thank you all.


    I have one more question that I should know, but I'll search first then ask!

+ 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. Replies: 0
    Last Post: 05-18-2013, 03:29 AM
  2. [SOLVED] Select last date with 2 dates in same cell
    By SimonsGE in forum Excel General
    Replies: 5
    Last Post: 04-06-2013, 01:51 PM
  3. Count Occurrence of date (6th April) between two dates...
    By noonoogizmo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2012, 06:21 AM
  4. [SOLVED] How can I select n number of rows that occurs after a certain marker?
    By rzhu87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2012, 10:11 PM
  5. Replies: 9
    Last Post: 03-30-2012, 07:54 PM
  6. How Many Times an Hour Occurs Between Two Dates
    By Jambonie in forum Excel General
    Replies: 4
    Last Post: 05-17-2011, 12:48 PM
  7. Compare Dates to see if date 1 occurs before or after date 2
    By ashton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2009, 08:59 AM
  8. [SOLVED] How do I select the nearest date from a ranges of dates?
    By gerrit in forum Excel General
    Replies: 3
    Last Post: 02-12-2006, 12:50 PM

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