SOLVED

Power Query Merge Question

Occasional Contributor

Hello All,

 

Suppose I have two files PQ1 and PQ2 and data in PQ1 and PQ2 are as follows:

 

Legal NameDealOrigination DateMaturity Date
TMTD3513/31/20163/31/2023

 

DealLegal NameOrigination DateMaturity DateExtended Maturity Date
D351TMT3/31/20163/31/20223/31/2023

 

When I use PQ and merge I will get following result

Legal NameDealOrigination DateMaturity DateDealLegal NameOrigination DateMaturity DateExtended Maturity Date
TMTD3513/31/20163/31/2023D351TMT3/31/20163/31/20223/31/2023

 

 

Now As you can see that extension has place so result that I actually want to see is:

 

Legal NameDealOrigination DateMaturity DateDealLegal NameOrigination DateMaturity Date
TMTD3513/31/20163/31/2023D351TMT3/31/20163/31/2022
TMTD3513/31/20163/31/2023D351TMT3/31/20223/31/2023

 

Could anyone advise how to get above result?

 

 

 

3 Replies

@Cmpunk The attached file contains a PQ solution that matches your example, though I suspect that your real life data is not as simplistic as you projected it. So, it might work at all in the real world at all.

 

Thanks Riny for your solution. I have one doubt when you added custom column and wrote following M-code: Table.AddColumn(#"Added Index", "OD2", each if [Maturity Date] <> [Extended Maturity Date] then [Origination Date] else #"Filled Down"[Maturity Date]{[Index]-1})

I am not familiar with M-language yet? Is there any other way to implement this logic?

Thank you for your response.
best response confirmed by Cmpunk (Occasional Contributor)
Solution

@Cmpunk Can't judge how the logic could be altered without seeing some real data. Many transformations in PQ can be done by just clicking the correct buttons, but at some point in time you'll find yourself needing to write or edit M-code in order to achieve more complicated goals. So, it's inevitable that you have to start learning about it.