Get closest date based on matching mutiple criteria in Excel -


i have 2 tabs below in excel:

table 1:

    date      vehicle number      planned leave time    actual leave time   8/7/2017        10001            8/7/17 4:59    

table 2:

  date   vehicle number   actual leave time 8/7/2017    10001          8/7/17 4:29 8/7/2017    10001          8/7/17 5:59 8/7/2017    10001          8/6/17 3:05 pm 8/7/2017    10003          8/6/17 2:05 pm 

i want actual leave time table 2 based on matching same date, same vehicle number between table 1 , table 2;

also, can see, there multiple records same vehicle , same date in table 2, think have compare time (8/7/17 4:59 am) time in table 2 on 8/7/2017 , vehicle 10001, closest time, has minimum abs difference between planned time , active time.

so can please tell me formula should use in excel in order achieve purpose?

thanks pudge

i turned data tables tables , used structured references, doesn't matter tables located. in addition, formulas , references automatically update if add rows either table. also, can rename tables meaningful, if like.

the formula array formula must entered holding down ctrl+shift while hitting enter. if correctly, excel place braces {...} around formula:

=index(table2[actual leave time], match(min(abs(([@date]=table2[date])*([@[vehicle number]]=table2[vehicle number])*table2[actual leave time]-[@[planned leave time]])),abs(([@date]=table2[date])*([@[vehicle number]]=table2[vehicle number])*table2[actual leave time]-[@[planned leave time]]),0)) 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -