+ Reply to Thread
Results 1 to 12 of 12

MATCH and time data - function not working

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question MATCH and time data - function not working

    Hi, I’m learning to use the MATCH function (with the aim to master its combination with INDEX in the end), but as often happens when you’re new to something, I got stuck pretty much the moment I started:

    All I’m trying to do at the moment, is to get the MATCH function to work with a database that contains time (see Column A), and a sample collection of certain time points (see Column B). The goal is for MATCH to return the corresponding element when it finds each of the ‘sample time’ points, and leave the cells blank when there’s no match to be found rather than showing an error message. To do this I’ve put in cells B18:B21 some formulas (which are listed in C18:C21 for easy referencing).

    A B C
    1 Database Sample
    2 00:00:01 00:00:00
    3 00:00:02 00:00:15
    4 00:00:03 00:01:20
    5 00:00:04 00:02:50
    6 00:00:05 00:10:00
    7 00:00:06 00:12:43
    8 00:00:07 00:14:02
    9 00:00:08 00:20:09
    10 00:00:09 00:25:50
    11 00:00:10 00:35:48
    12 00:00:11 00:48:18
    13 00:00:12 00:55:27
    14 00:00:13
    15 00:00:14
    16 00:00:15
    17 00:00:16 Result Formula
    18 00:00:17 =IFERROR(MATCH(B2,$A$2:$A$30,0),"")
    19 00:00:18 #N/A =MATCH(B3,$A$2:$A$30,0)
    20 00:00:19 =IFERROR(MATCH(B4,$A$2:$A$30,0),"")
    21 00:00:20 =IFERROR(MATCH(B5,$A$2:$A$30,0),"")
    22 00:00:21
    23 00:00:22
    24 00:00:23
    25 00:00:24
    26 00:00:25
    27 00:00:26
    28 00:00:27
    29 00:00:28
    30 00:00:29

    As you can see, it doesn’t work. Cell B19 is supposed to display 15 but just gives me the blank, and when I removed the ‘IFERROR’ part of the formula to try to figure out what went wrong, the cell then shows ‘#N/A’ which indicates that there’s no match available. This is clearly incorrect, so I tried to trouble shoot.

    I could only assume it was the data itself that caused the problem, to test this I copied the data value from cell A16 into cell B3 and the formula in B19 starts working just fine, as if by magic. OK, so we’re getting closer to the bottom of this.

    But that’s where my progress ends. When I manually entered the time data into cell B3, the formula in B19 wend back to displaying blank or #N/A, just like before.

    It just doesn’t make any sense why Excel would do this. To me, a cell that says “00:00:15 AM” contains the same data as another cell that says “00:00:15 AM”, whether the time is manually entered or copied from another cell. I tried various formats for these cells just in case there’s some minor variance that wasn’t clearly shown, but nothing could be identified.

    Now I’m truly confused and frustrated. Could anyone help please?

  2. #2
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: MATCH and time data - function not working

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: MATCH and time data - function not working

    Sorry all, I tried to attached the problem in an Excel file but my computer freezes every time. So I tried to space the data in a way that shows the different columns clearly but somehow it all got pushed together... Guess I also need a lesson in Word editing (or is it forum posting?).

  4. #4
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: MATCH and time data - function not working

    Quote Originally Posted by xtong View Post
    Sorry all, I tried to attached the problem in an Excel file but my computer freezes every time.
    Instead of using this forum file-attachment feature, upload an example Excel file to any file-sharing website and post the public/share URL in a response here. Some free websites:

    Dropbox: http://dropbox.com
    Box.Net: http://www.box.net/files
    MediaFire: http://www.mediafire.com
    FileFactory: http://www.filefactory.com
    FileSavr: http://www.filesavr.com
    RapidShare: http://www.rapidshare.com
    Windows OneDrive: http://onedrive.live.com

    Quote Originally Posted by xtong View Post
    So I tried to space the data in a way that shows the different columns clearly but somehow it all got pushed together.
    I think it is okay as-is. But to get things spaced the way you want, either use this forum's table feature or simply put CODE and /CODE tags around the text, format the text in Notepad or similar plain-text editor (not MS Word), and copy-and-paste the text between the CODE and /CODE tags.

    But it might not be worth the trouble. The MATCH might fail because the numeric value of the lookup time does not exactly match the numeric value of the times in the lookup table.

    That is why we need to have the example Excel file, not an image and not retyped text: the devil is in the details.

  5. #5
    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,926

    Re: MATCH and time data - function not working

    Quote Originally Posted by joeu2004 View Post
    Instead of using this forum file-attachment feature, upload an example Excel file to any file-sharing website and post the public/share URL in a response here. Some free websites:

    Dropbox: http://dropbox.com
    Box.Net: http://www.box.net/files
    MediaFire: http://www.mediafire.com
    FileFactory: http://www.filefactory.com
    FileSavr: http://www.filesavr.com
    RapidShare: http://www.rapidshare.com
    Windows OneDrive: http://onedrive.live.com
    Sorry, but we prefer that you NOT use file-hosting sites like these. Not all members are able - or willing - to access them.

    If you are having a problem uploading a file, perhaps it is too large? We only need a small, representative sample of what you are working with, as it relates to your question

    Thanks
    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

  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,926

    Re: MATCH and time data - function not working

    xtong, you need to know this about how excel handles time...
    time is a decimal of 1 (day), so for instance 06:00 AM is actually just 0.25, 12 noon is .05 and 06:00 PM (18:00) is 0.75. Excel formats it to something we see as a time

    Matching time can be problematic, because if you look at a few examples....
    G
    H
    52
    0:16
    0.011111111111111100
    53
    0:15
    0.010416666666666700
    54
    0:01
    0.000694444444444444
    55
    H53-H54
    0.000694444444444445

    G52:G54 are samples of time entered directly into excel
    H53:H54 are what the underlying values look like
    H55=H52-H53

    As you can see, H54 (1 minute entered) and H55 (16 mins - 15 mins) are pretty much the same...but pretty much is not exactly, and that 0.000000000000000001 makes a BIG difference when you are trying to find an exact match. You can test this yourself on a variety of times.

    1 way around is to round (up or down) on both sets of values (your table and your match criteria) to something like 10 decimal places...play with the amount to give you te accuracy (or lack there-of) that you are comfortable with

  7. #7
    Registered User
    Join Date
    10-09-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: MATCH and time data - function not working

    Thank you FDibbins, I think that's exactly why the formulas wouldn't work. Guess I picked a troublesome type of data to begin with, I usually deal with financial data and the best precision I've seen is 4 decimal places

  8. #8
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: MATCH and time data - function not working

    Quote Originally Posted by FDibbins View Post
    1 way around is to round (up or down) on both sets of values (your table and your match criteria) to something like 10 decimal places...play with the amount to give you te accuracy (or lack there-of) that you are comfortable with
    IMHO, it is bad programming practice to round time arithmetic to an arbitrary number of decimal places. That just replaces one inaccurate binary representation with another. Even if we try to be consistent with "both sets of values", it might probably cause problems somewhere eventually. Moreover, it is unusual to round time constants, which is often one set of values.

    The correct procedure is to round time arithmetic to the time precision that we require. For example, if time arithmetic should be accurate to one minute, round to one minute using one of the following paradigms:

    --TEXT(A1-B1,"[h]:mm")
    or
    ROUND((A1-B1)*1440,0)/1440

    The double-negate converts the text result to numeric time.

    One advantage of using ROUND: we can easily opt to ROUNDDOWN or ROUNDUP, if we require. Moreover, "[h]:mm" does not work for all regions, by default.

    On the other hand, we might expect the TEXT conversion to result in exactly the same binary representation as conversion of the equivalent constant. Theoretically, division by 1440 might result in a slightly different binary representation, differing by an infinitesimal amount. (But in practice, I believe it does not.)

  9. #9
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: MATCH and time data - function not working

    Errata...
    Quote Originally Posted by joeu2004 View Post
    ROUND((A1-B1)*1440,0)/1440
    [....]
    Theoretically, division by 1440 might result in a slightly different binary representation, differing by an infinitesimal amount. (But in practice, I believe it does not.)
    Actually, that is incorrect. For example, if A1 is 23:58 and B1 is =ROUND(A1*1440,0)/1440, the formula =MATCH(A1,B1,0) and even =MATCH(A1,B1,1) return the #N/A error (no match) because B1 is infinitesimally greater than A1.

  10. #10
    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,926

    Re: MATCH and time data - function not working

    joeu2004 thanks for the math lecture.

    Perhaps read entire posts next time, i had already covered your dissertation...
    1 way around is to round (up or down) on both sets of values (your table and your match criteria) to something like 10 decimal places...play with the amount to give you te accuracy (or lack there-of) that you are comfortable with

  11. #11
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: MATCH and time data - function not working

    Quote Originally Posted by FDibbins View Post
    joeu2004 thanks for the math lecture.
    Perhaps read entire posts next time, i had already covered your dissertation...
    1 way around is to round (up or down) on both sets of values (your table and your match criteria) to something like 10 decimal places...play with the amount to give you te accuracy (or lack there-of) that you are comfortable with
    Not surprisingly, you entirely missed the point of my "lecture".

    Selecting 10 decimal places or even "playing with the amount" (decimal places?) is not the appropriate way to round time. That just replaces one inaccurate binary representation with another.

    You suggest doing that with "both sets of values" so that both sets are equally inaccurate. But IMHO, it is ludicrous to expect a user to enter ROUND("16:28",10) instead of simply 16:28.

  12. #12
    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,926

    Re: MATCH and time data - function not working

    i missed nothing, i ignored it.

    This discussion is now ended
    thanks

+ 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. [SOLVED] Index, Match & And function doesn't seem to be working when there is duplicate data
    By penexcel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-26-2013, 07:08 PM
  2. [SOLVED] Problems with Match Working on time values 00:00:00. A bug?
    By JungleJme in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2013, 05:18 AM
  3. Match command not working all the time.
    By kjsconv in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2012, 01:38 PM
  4. MATCH function within INDIRECT function not working
    By mgerada in forum Excel General
    Replies: 2
    Last Post: 09-04-2011, 08:37 AM
  5. Index-Match Function Not Working all the time
    By hoosierhunter in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-08-2007, 06:58 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