Forum Discussion

tgjones43's avatar
tgjones43
Icon for Helper IV rankHelper IV
3 years ago

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

 

DateTimeAdditional Data
01/01/202200:00 
01/01/202200:15 
01/01/202200:30Y
01/01/202200:45 

 

Table 2

 

DateTimeMeasurement 1Measurement 2Measurement 3
01/01/202200:34123

 

Desired result

 

DateTimeAdditional DataMeasurement 1Measurement 2Measurement 3
01/01/202200:00    
01/01/202200:15    
01/01/202200:30Y123
01/01/202200:45    

1 Reply

  • 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