+ Reply to Thread
Results 1 to 21 of 21

Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

  1. #1
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hi Guys,

    I am struggling to find a suitable formula to capture only dates that have numbers corresponding to them on the same row. Please see attached the example. The data I have has dates in one column and levels on the next column. I need to write a formula that will have the results in column E. I mixed formulas such as Index and Match. I think I am close, but with your help will be easier.
    Can you please have a go and let me know your thoughts?
    Thanks a lot.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    use this array formula in E3, copied down:

    =IFERROR(INDEX(B:B,SMALL(IF($C$3:$C$33>0,ROW($C$3:$C$33)),ROWS($E$3:E3))),"")

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hi Glenn, thanks a lot for your reply. It actually does the job.
    What if I need cell E3 as my start date (manually entered) and the the cells below it with a formula showing only greater dates with levels than the manually entered one. My database has ongoing rolling dates.
    Is there any way?
    Thanks once again!!
    Best regards,
    LEORITY

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Yes. All you need to do is add another IF condition into the formula. Set here to take date from E2...


    =IFERROR(INDEX(B:B,SMALL(IF($C$3:$C$33>0,IF($B$3:$B$33>=$E$2,ROW($C$3:$C$33))),ROWS($E$3:E3))),"")

    again, entered as an array.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hey Glen, thanks a lot for you solution!! I was far from getting it right.
    This made my working tasks easier.
    Thank you once again!!
    Leority

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  7. #7
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hi Glenn,

    Now I need to capture the dates with a value in the whole data range, and the date has to be shown only once (one different date per row).
    I tried removing the MATCH part of the formula leaving blank the "column" part of the index formula. That returned dates for all columns with a value on that particular date. So if there is a date with a value in 4 columns, the date is repeated 4 times, instead of one.
    The formula I came up with is (in cell C8 - file attached):
    =IFERROR(INDEX(H:H,SMALL(INDEX(((INDEX($I$6:$N$10000,,)="")+$H$6:$H$10000<=C$7))*10^10+ROW($H$6:$H$10000),0),ROWS(C$8:C8))),C7+1)
    Can you please help with a work around this?
    Thank you very much..
    Attached Files Attached Files

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

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Try this
    ARRAY formula in C8, then drag down
    Please Login or Register  to view this content.
    ARRAY formula is used

    To enter ARRAY formula
    Paste the formula
    Press F2
    Press Ctrl+Shift+Enter keys together.
    formula will be covered with{} brackets by excel.
    Attached Files Attached Files

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    In your posted sheet, are you looking at ALL columns (I to N) or ONLY the one specified by C2??

  10. #10
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hi, I am actually after the whole range of columns. For example, the date 21-Apr has 3 values in different columns, but I need a date with at least 1 value. Does it make sense?

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Yep.

    No problem. I had to move your manually inputted start date. With it JUST above your results, it would have EXCLUDED any results on the start date. array-netered formula in C8, copied down:

    =IFERROR(INDEX(H:H,SMALL(IF(($I$6:$N$39<>"")*COLUMN($I$6:$N$39)*($H$6:$H$39>=$C$6)*(COUNTIF($C$7:C7,$H$6:$H$39)=0),ROW($H$6:$H$39)),1)),"")

    How does this look?

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Thumbs up Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hey Glenn,

    Thank you so much for your wide knowledge of Excel formulas! I have modified the formula a little to suit my needs.
    In cell C8 it is now:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Also attached the file back to you.
    I have removed the Results cell and placed the input date on its place.

    Would you mind explaining how this formula works? If I manage to understand it a bit better, I won't be bothering you this much

    Thanks once again and again
    Attached Files Attached Files

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    In your first post describing the new request (Post 7) you wanted the dates returned to be greater than or equal to the manually inputted date. To do that, unless, you add some very awkward phrasing, it ABSOLUTELY need to move the selection cell to any cell OTHER than the one above the results. That is what I did. You have now changed your requirement to be greater than (and NOT greater than or equal to).

    That may be what you want, but logically it looks VERY strange. If you enter March 1st in c7, your first result is March 3rd, EVEN THOUGH there are matching results for March 1st.... Think very carefully about this... Will you / the intended users of the sheet ALWAYS be aware that they need to put in the date of the day before the date when they want the results to start. It is not logical and is really not a good plan!!!

    You have been warned....

    How does it work...

    One bit can be omitted. The column (XX:yy) bit.

    =IFERROR(INDEX(H:H,SMALL(IF(($I$6:$N$39<>"")*($H$6:$H$39>$C$7)*(COUNTIF($C$7:C7,$H$6:$H$39)=0),ROW($H$6:$H$39)),1)),"")

    For every non-blank cell in the 2D array, return TRUE, otherwise FALSE

    Return T/F for dates > manual day-before-the-desired-start-date (AWFUL!!!) and multiply, returns 1 (T) and 0 (F)

    Return only those results that do not appear above the cell in which the formula is in (this is where you need your awful "start date is the day before you REALLY want the results to start from" bit) - prevents repitition of multiple matching dates

    Return the row number IF all the previous criteria are TRUE, i.e. have a non-zero value. Returns row number or FALSE.

    The remainder returns the first instance of the date from column H that matches all the above criteria. On the next (and subsequent) row(s), the result above and the other instances of the first date are excluded by the COUNTIF bit.






    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Hi Glenn,

    I know it seems awkward/weird/strange...

    This data is to feed a table and the dates and numbers per location will be used to feed a chart from that table (with limited room - 15 rows only), and that is why I need to be able to input the starting date so I will ensure the shown data is now over 15 rows...

    I guess the only thing I am still missing is that I need to show data for certain locations every week (and locations will change over time). So I think I just need another if statement with a INDEX / MATCH to suit this requirement. On the attached example the highlighted cells have zeros on them (because the other locations have values), but I needed to show only the chosen locations and dates with values... Can you please help again?

    Thanks in advance.

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Nothing has been attached...

  16. #16
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Oops, my bad. Here it is.
    Attached Files Attached Files

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    The first couple of things that I've tried have failed miserably. Can you try this as a workaround:

    =IFERROR(1/(1/INDEX($I$6:$N$39,MATCH($C6,$H$6:$H$39,0),MATCH(D$5,$I$5:$N$5,0))),NA())

    in D6, copied across and down. This converts all 0s to #N/A errors, which Excel will ignore in drawing a chart. If they're hard on the eyes, you can always use conditional formatting to change their text colour to white. Still there, but you can't see them....

  18. #18
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    The workaround works, but I still need to show the dates and the chart side by side. So I actually needed the formula to use only the locations show on the headings. Is it possible?

  19. #19
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    In C7, an array formula:

    =IFERROR(INDEX(H:H,SMALL(IF(((INDEX($I$6:$N$39,,MATCH($D$5,$I$5:$N$5,0))<>"")+(INDEX($I$6:$N$39,,MATCH($E$5,$I$5:$N$5,0))<>"")+(INDEX($I$6:$N$39,,MATCH($F$5,$I$5:$N$5,0))<>""))*($H$6:$H$39>$C$6)*(COUNTIF($C$6:C6,$H$6:$H$39)=0),ROW($H$6:$H$39)),1)),"")

    I was being stupid yesterday... I got my brackets in the wrong places and I got my ANDs and ORs muddled up!!

    If you want to suppress the zeros in your chart, use this for the lookups:
    =IFERROR(1/(1/VLOOKUP($C6,$H$5:$N$39,MATCH(D$5,$H$5:$N$5,0),FALSE)),NA())

    and then use CF to make them invisible, by changing their text colour to white.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    08-20-2015
    Posts
    21

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Wowwww! That surprised me for good!
    Thanks again for all and sorry for being a pest hahaha.
    That is why I love excel - it can do everything (if you know how)!!! And that is why I love this forum! People like you, make the difference
    Best regards,
    LEORITY.

  21. #21
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Capture Only Dates With Corresponding Numbers (no empty cells)

    Any time...You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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: 3
    Last Post: 03-20-2015, 07:04 PM
  2. [SOLVED] Formula to capture taken taken in hours between two dates and time
    By ed.mcardle in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-25-2015, 04:36 PM
  3. [SOLVED] Help with Formula to capture dates to be populated on a calendar
    By Inez15 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-08-2013, 06:27 AM
  4. Help with a formula using dates and empty cells
    By ChrisHallas in forum Excel General
    Replies: 2
    Last Post: 06-27-2012, 10:02 AM
  5. Formula to capture data in cells that are after it
    By maani in forum Excel General
    Replies: 10
    Last Post: 08-17-2009, 04:56 AM
  6. How do I set up a formula to capture info from many other cells?
    By JoelWMD in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  7. [SOLVED] How do I set up a formula to capture info from many other cells?
    By JoelWMD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-10-2005, 03:05 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