Jan 22 2020 08:37 AM
Hi,
I have 2 datasets that I would like to merge together. There is a common id field between the two but I need the two datasets to also align by date. There is no common date field. One dataset has a created date field and the second dataset has a completed date field. I would like to align the datasets by id and date if the 2 dates are within 365 days of each other. Is there a way to do this in Excel?
Thank you!
Jan 22 2020 08:42 AM
@LPSUCSF -
You could merge/join the tables using Power Query. While in PQ, you can than evaluate the dates then filter out any that do not met the criteria. If you could provide a data sample we could help with a more detailed solution.
Jan 22 2020 09:01 AM
Jan 22 2020 10:41 AM
Jan 22 2020 11:18 AM
@ChrisMendoza Please see updated Excel file with desired merge results. I need the rows to align where the created date and completed date are with 365 days of each other. Thank you!
Jan 22 2020 11:55 AM
Jan 22 2020 11:58 AM
@ChrisMendoza That's great! What did you do? Thank you!
Jan 22 2020 12:03 PM
@LPSUCSF -
Data > Queries & Connections > Right-Click Edit to see what was done in the Query Editor.
In the Step 'Added Custom' I added IF ELSE logic as:
if Duration.Days([Dataset2.completeddate]-[createddate]) > 365 then null else if Duration.Days([Dataset2.completeddate]-[createddate]) <= 0 then null else Duration.Days([Dataset2.completeddate]-[createddate])
Producing:
Then just filtered out NULL.
Jan 22 2020 02:44 PM
@ChrisMendoza Hi. I'm not familiar with Power Queries. Could you please provide a link to how you did this? I am unable to follow what you did. I don't see Queries and Connections in my Data tab. I see only Connections. Thank you.
Jan 22 2020 02:50 PM
Jan 22 2020 02:53 PM
@ChrisMendoza I have Excel 2016
Jan 22 2020 02:56 PM
@LPSUCSF - Looks like it's 'Show Queries' as shown in https://www.youtube.com/watch?v=zjnFKS9iXPs
Jan 22 2020 03:58 PM
@ChrisMendoza I think I finally got it. Will need to do some data clean up. This was definitely faster than by hand.