Forum Discussion
Conditional merge of two tables
Hi all
I have 2 tables that I would like to merge into 1 but I can't figure out how to do it. The 2 tables below show a simplified snippet of data. Table 1 has values for several parameters (not shown in table) collected every 15 minutes. Table 2 has extra values collected at a random time. I have manually added a column to table 1 [Additional Data] to give a Y at the 15 minute interval that most closely matches the time when that extra sample was collected. I would then like the measurement columns from Table 2 added to the end of Table 1, as shown in the final table.
Is there a way to do this in Power Query? Thank you!
Table 1
| Date | Time | Additional Data |
| 01/01/2022 | 00:00 | |
| 01/01/2022 | 00:15 | |
| 01/01/2022 | 00:30 | Y |
| 01/01/2022 | 00:45 |
Table 2
| Date | Time | Measurement 1 | Measurement 2 | Measurement 3 |
| 01/01/2022 | 00:34 | 1 | 2 | 3 |
Desired result
| Date | Time | Additional Data | Measurement 1 | Measurement 2 | Measurement 3 |
| 01/01/2022 | 00:00 | ||||
| 01/01/2022 | 00:15 | ||||
| 01/01/2022 | 00:30 | Y | 1 | 2 | 3 |
| 01/01/2022 | 00:45 |
1 Reply
- BA_Pete
Super User
Hi tgjones43 ,
If you repeat the logic that you used to put the "Y" in Table1, but kind of in reverse, you can create a new column in Table2 that converts the actual read time to the nearest quarter hour.
From here, you can just merge on Table1[Date]&[Time] = Table2[Date]&[AdjustedTime]
Pete