Find the value for the exact or closest time

alvintranvcu123

New Member
Joined
Jan 16, 2025
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Dear all/

I have the temperature data, which were measured from 02 sources. The measuring times may be different. They could be the same or near the same in 02 sources.
I would
I would like to make it a table.

1. Exact time: show 02 temp values

2. Not exact time: show 02 temp which one temp is the closest time in table 1.

( 1)
10:04:04 AM1455
10:04:14 AM1463
10:04:24 AM1458
10:04:34 AM1463
10:04:44 AM1472
10:04:54 AM1487
10:05:04 AM1496
10:05:14 AM1504
(2)
10:01:59 AM1565
10:04:07 AM1548
10:05:30 AM1568
10:06:00 AM1564
10:07:27 AM1566
10:08:27 AM1535
10:09:31 AM1545
10:09:57 AM1545
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Welcome to the Forum!

Your question isn't clear. Is this what you want to do - find the closest matching time in Table 1 for each time in Table2?

ABCDEFGH
1Table1Table2
2TimeTemperatureTimeTemperatureTable1 timeTable1 temperature
310:04:04 AM145510:01:59 AM156510:04:04 AM1455
410:04:14 AM146310:04:07 AM154810:04:04 AM1455
510:04:24 AM145810:05:30 AM156810:05:14 AM1504
610:04:34 AM146310:06:00 AM156410:05:14 AM1504
710:04:44 AM147210:07:27 AM156610:05:14 AM1504
810:04:54 AM148710:08:27 AM153510:05:14 AM1504
910:05:04 AM149610:09:31 AM154510:05:14 AM1504
1010:05:14 AM150410:09:57 AM154510:05:14 AM1504
11
Sheet1
Cell Formulas
RangeFormula
F3:F10F3=LET(t,ABS(Table1[Time]-[@Time]),XLOOKUP(MIN(t),t,Table1[Time]))
G3:G10G3=XLOOKUP([@[Table1 time]],Table1[Time],Table1[Temperature])
 
Upvote 0
Table 1 is fixed.
I would like to keep all data on table 1, add one new column on the table 1. Look up the temp from table 2 to new column.

If time is the exact, add this temp (table 2) in new column.
if time is different, add the temp (table 2) is closest the time in table 1.

Table 1 From table 2
10:33:04 1509 1508 ( exact)
10:35:26 1527 1523 ( measured at 10.34:59 but closest to 10:35:26 in table 1, so take it )
 
Upvote 0
1737017041458.png
 
Upvote 0
So like this then?

ABCDEF
1Table2Table1
2TimeTemperatureTimeTemperatureTable2 temperature
310:01:59 AM156510:00:00 AM14551565
410:04:07 AM154810:01:00 AM14631565
510:05:30 AM156810:02:00 AM14581565
610:06:00 AM156410:03:00 AM14631565
710:07:27 AM156610:04:00 AM14721548
810:08:27 AM153510:05:00 AM14871568
910:09:31 AM154510:08:00 AM14961535
1010:09:57 AM154510:10:00 AM15041545
Sheet1
Cell Formulas
RangeFormula
F3:F10F3=LET(t,ABS(Table2[Time]-[@Time]),XLOOKUP(MIN(t),t,Table2[Temperature]))

If you want to allow for the possibility of two matching closest times, you could use:

=LET(t,ABS(Table2[Time]-[@Time]),AVERAGE(FILTER(Table2[Temperature],MIN(t)=t)))
 
Upvote 0
Look cool.

The closest time= I'd like to take 01 temp value only.

10:01:59 AM (1565), in table 1 it should only show in row 10:02:00 ( not others) because only closest.
 
Upvote 0
I hope I'm not over-complicating this (and it would be simpler to use helper columns) ....

ABCDEFG
1Table2Table1
2TimeTempTimeTempTable 2 temp
310A9PA
412B15QC
516C19RD
620D21S 
730E26T 
835F31UE
941VF
10
Sheet1
Cell Formulas
RangeFormula
G3:G9G3=LET(A,BYROW([Time],LAMBDA(r,LET(a,ABS(Table2[Time]-r),XLOOKUP(MIN(a),a,Table2[Temp])))),B,BYROW(Table2[Time],LAMBDA(r,LET(a,ABS([Time]-r),XLOOKUP(MIN(a),a,[Temp])))),INDEX(IF(MMULT(--(A=TRANSPOSE(A)),SEQUENCE(ROWS(A),,,0))=1,A,IF(XLOOKUP(A,Table2[Temp],B)=[Temp],A,"")),ROW([@Time])-ROW(Table1[[#Headers],[Time]])))

I've used numbers rather than times, and A,B,C etc rather than numbers for the temperature, just to make it easier to check. I haven't done much testing.
 
Upvote 0
Thanks so much. How do I copy your formula to our excel file?
This formula is too complex.

I would like to do the format, then just paste new data & done.

1737095082673.png
 
Upvote 0
I mean I copy your formula to our Excel cell, but it's not work. Your formula is beyond my knowledge, so I'm happy to copy your formula, paste to my cell is OK.

But it didn't work.
 
Upvote 0

Forum statistics

Threads
1,225,613
Messages
6,186,003
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top