May 14 2022 10:21 PM
May 14 2022 10:21 PM
I was able to merge(inner join) a transaction table with an owner info table using account number as my key to get the following results:
I need the transactions to be linked to the current owner(s) of the account. But as you can see, for the 9/16/2016 transaction, it is also linked to an owner who did not own the account until much later. Similarly, the 11/27/2020 transaction needs to be linked to the newer owner, so I am looking for something like this:
Since the secondary owner does not change, Mary applies to both transactions.
For other accounts, it is also possible for the primary owner to remain the same while the secondary owner has changed. There are also accounts in which there are up to 4 secondary owners.
So, in short, I need the transaction dates to match up with the previous, most recent Owner Change Date for both primary and secondary owner(s).
I am new to Power Query, so I do not know whether this is better done using PQ or simply Excel functions/formulas. Or maybe there are additional data manipulation/transformation steps I need to take before this...?
Any input would be greatly appreciated.
May 15 2022 02:44 AM
@Cindysc1218 Difficult to be thoroughly test on such a small data set, but the attached file seems to achieve what you describe. Please see if this would work on your real data as well. If not, come back with a more realistic example of your data. Perhaps you can share a link to your workbook (Onedrive, Dropbox or similar).
May 15 2022 05:57 PM - edited May 15 2022 05:58 PM
@Riny_van_Eekelen Hi, Riny! Thank you for answering my question. It was good to know I was on the right track and I was able to take action that appears to be working the way I need it to (I've spent much time examining the results).
I had done something similar to your method, but I had to make some adjustments that I am not sure why:
May 15 2022 09:31 PM
@Cindysc1218 My understanding was that you can only have 1 same type of owner for each account 1 Primary, 1 Secondary1, 1 Secondary2 etc. But never 2 Primaries or 2 Secondary1's etc,.
The sample data contained instances where there were 2 Primary owners of which you want to keep the one that changed most recently. That's why I sorted by ChangeDate in descending order. That becomes important in the next step of removing duplicates.
Now, why use those three columns to remove the duplicates? I figured that the combination of these three were the key to identifying same transactions by owner type. The "remove duplicates" step "joins" all of these three columns and keeps the first one (i.e. the one with then most recent change date) when it finds duplicates. So if you have it like below (key fields, change date and name), sorted by Change Date in descending order, John will be removed.
Nov-27, 1000, Jul-8 2020, P, James
Nov-27, 1000, Sep-1 2015, P, John <<<<< duplicate that will be removed
Nov-27, 1000, Sep-1 2015, S1, Mary