Power Query chose a value <=date

ursua

New Member
Joined
Jan 9, 2020
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have towo tables in excel, a source table and a destination table. In a source table there is a number, a timestamp and a value. In destination table there is a number, timestamp.
Source table:
NumberDatestampvalue
1​
2023-07-24 11:15:40​
1​
2023-07-24 11:15:40​
A/S/S
1​
2023-07-24 11:15:40​
A/S/S
1​
2023-07-25 09:57:33​
A/S/M
1​
2023-07-25 09:57:33​
A/S/M
1​
2023-07-25 09:57:33​
A/S/M
1​
2023-08-01 18:52:30​
A/S/S
1​
2023-08-01 18:52:30​
A/S/S
1​
2023-08-01 18:52:30​
A/S/S
1​
2023-09-07 17:05:35​
A/S/X
1​
2023-09-07 17:05:35​
A/S/X
1​
2023-09-07 17:05:35​
A/S/X
1​
2023-09-20 08:07:50​
B/C/X
1​
2023-09-20 08:07:50​
B/C/X
1​
2023-09-20 08:07:50​
B/C/X
1​
2023-10-16 12:27:20​
A/S/S
1​
2023-10-16 12:27:20​
A/S/S
1​
2023-10-16 12:27:20​
A/S/S
1​
2023-12-01 08:45:00​
B/C/Z
1​
2023-12-01 08:45:00​
B/C/Z
1​
2023-12-01 08:45:00​
B/C/Z
1​
2023-12-22 15:39:30​
B/C/F
1​
2023-12-22 15:39:30​
B/C/F
1​
2023-12-22 15:39:30​
B/C/F
1​
2023-12-28 12:25:00​
A/S/S
1​
2023-12-28 12:25:00​
A/S/S
1​
2023-12-28 12:25:00​
A/S/S
and a destination
NumberCreated abCreatedvalue
1​
2023-07-24 10:56:55​
2024-04-15 13:39:25​
1​
2023-07-24 10:56:55​
2024-04-17 10:35:45​
1​
2023-07-24 10:56:55​
2024-04-17 12:05:00​
1​
2023-07-24 10:56:55​
2024-04-17 15:07:25​
1​
2023-07-24 10:56:55​
2024-04-18 12:01:50​
1​
2023-07-24 10:56:55​
2024-04-18 13:16:20​
1​
2023-07-24 10:56:55​
2024-04-21 18:39:45​
1​
2023-07-24 10:56:55​
2024-04-22 10:59:10​
1​
2023-07-24 10:56:55​
2024-04-24 11:29:31​
1​
2023-07-24 10:56:55​
2024-04-24 18:15:40​
1​
2023-07-24 10:56:55​
2024-04-26 14:55:40​
1​
2023-07-24 10:56:55​
2024-04-26 15:43:45​

What i need to achieve is to put a value from source to destination for every number (of course there are more than just a 1) depending on timestamp. the timestamp from source should be equal or first one before the created timestamp in destination. wouldn't be a problem if the timestamps were exactly the same (simple merge then) but how to achieve it with < or = ?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Power Query:
    // your tables are destination_table and source_table
    rename = Table.RenameColumns(destination_table, {"Created", "Datestamp"}),
    cmb = Table.Sort(rename & source_table, {"Number", "Datestamp", "Created ab"}),
    fill_up = Table.FillUp(cmb,{"value"}),
    filter = Table.SelectRows(fill_up, each ([Created ab] <> null))
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,155
Members
452,615
Latest member
bogeys2birdies

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