Index/Match Time Match Errors

柔情痞子 提交于 2020-01-03 02:46:05

问题


I am using index/match to extract data by matching date/times using INDEX(D:D,MATCH(A2,B:B,0)) A:A column of date/times has been manually entered. B:B column of date/times input as B2+time(,30,) and copied down.

After 3 lines the formula gives #N/A as an answer.

It has something to do with the times not matching exactly even though A5=B5 gives a true result that row gives #N/A If I copy A:A to B:B i.e. all manually entered times it works perfectly. Please help.

A               B               C        D  E   F   G       H   I       J                   K
AET Entered     AET + 30        =    volts  lo  i1  i0      vl1 vl0     Value AET           Value Time +30
1/08/15 10:00   1/08/15 10:00   TRUE    36  36  36  36      36  36      42217.4166666667000 42217.4166666667000
1/08/15 10:30   1/08/15 10:30   TRUE    23  23  23  23      23  23      42217.4375000000000 42217.4375000000000
1/08/15 11:00   1/08/15 11:00   TRUE    44  44  44  44      44  44      42217.4583333333000 42217.4583333333000
1/08/15 11:30   1/08/15 11:30   TRUE    55  44  44  #N/A    44  #N/A    42217.4791666667000 42217.4791666667000
1/08/15 12:00   1/08/15 12:00   TRUE    13  55  55  #N/A    55  #N/A    42217.5000000000000 42217.5000000000000
1/08/15 12:30   1/08/15 12:30   TRUE    32  13  13  #N/A    13  #N/A    42217.5208333333000 42217.5208333333000
1/08/15 13:00   1/08/15 13:00   TRUE    56  32  32  #N/A    32  #N/A    42217.5416666667000 42217.5416666667000
1/08/15 13:30   1/08/15 13:30   TRUE    70  56  56  #N/A    56  #N/A    42217.5625000000000 42217.5625000000000
1/08/15 14:00   1/08/15 14:00   FALSE   43  70  70  #N/A    70  #N/A    42217.5833333333000 42217.5833333334000
1/08/15 14:30   1/08/15 14:30   TRUE    31  43  43  #N/A    43  #N/A    42217.6041666667000 42217.6041666667000
1/08/15 15:00   1/08/15 15:00   TRUE    21  31  31  #N/A    31  #N/A    42217.6250000000000 42217.6250000000000
1/08/15 15:30   1/08/15 15:30   FALSE   11  21  21  #N/A    21  #N/A    42217.6458333333000 42217.6458333334000
1/08/15 16:00   1/08/15 16:00   TRUE    66  11  11  #N/A    11  #N/A    42217.6666666667000 42217.6666666667000
1/08/15 16:30   1/08/15 16:30   TRUE    45  66  66  #N/A    66  #N/A    42217.6875000000000 42217.6875000000000
1/08/15 17:00   1/08/15 17:00   FALSE   23  45  45  #N/A    45  #N/A    42217.7083333333000 42217.7083333334000

回答1:


I'll leave @AxelRichter to post the answer in his comment, which involves rounding the timestamps and referencing the rounded numbers to avoid floating point precision.

An alternative solution would be to simply allow VLOOKUP/MATCH to pick up the 'nearest value' result, using the final argument in each function. ie:

=INDEX(D:D,MATCH(A2,B:B,1))

Keep in mind that this will only work if your data is sorted. It has the added benefit that if a missing result should naturally be the next closest row, that row is picked up - and likewise it has the added cost that it will not warn you when a match isnt found.




回答2:


This is an issue with floating point precision. As you see even the = comparison fails with 1/8/15 14:00 42012,5833333333 vs. 42012,5833333334. The exact matching with MATCH(..,0) or VLOOKUP(.., FALSE) uses an other comparison method and so it fails more often. If we need exact matching date time values then we need those values ROUNDed the same count of decimals. So we need helper columns which ROUNDs A and B to 8 decimals and then use those helper columns in MATCH(..,0) or VLOOKUP(.., FALSE).

At least one helper column is needed since we could round the lookup value directly within the functions. But the lookup array we can not round that way.

Example:

Formulas:

B3downwards:

=B2+TIME(0,30,0)

C2downwards:

=A2=B2

D2downwards:

=MATCH(B2,A:A,0)

E2 downwards:

=MATCH(ROUND(B2,8),G:G,0)

G2downwards:

=ROUND(A2,8)


来源:https://stackoverflow.com/questions/34603682/index-match-time-match-errors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!