Forum

How to add merge an...
 
Notifications
Clear all

How to add merge and check if column was not deleted

4 Posts
2 Users
0 Reactions
144 Views
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Guys,

i have query like:

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Key", Int64.Type}, {"Key2", Int64.Type}, {"Col2", type text}, {"Col3", type text}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Key", "Key2"}, Table13, {"Key", "Key2"}, "Table13", JoinKind.Inner),
#"Removed Columns" = Table.RemoveColumns(#"Merged Queries",{"Table13"}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Key", "Key2"}, "Attribute", "Value"),
#"Removed Columns1" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"})
in
#"Removed Columns1"

And now in step #"Merged Queries"  i am merging table1 with Table13 using inner join. 
Where is the issue that Key2 in Table13 can be removed and i will get error:

Expression.Error: The column 'Key2' of the table wasn't found.
Details:
Key2

What i want to do is add If statetement or try statement and if Key2 was removed just use inner join for "Key" field. 
(use one column not 2 within inner join). 

How can i do this? 
Best,
Jacek

 
Posted : 09/06/2021 4:47 am
(@catalinb)
Posts: 1937
Member Admin
 

Please stop creating new topics on the same problem. The answer to this question was already posted here:
https://www.myonlinetraininghub.com/excel-forum/power-query/automating-repeating-steps-with-power-query-function#p20677

All your other new topics you created are related to the same problem, please post your follow-ups on the same topic.

 
Posted : 09/06/2021 5:14 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi i am going there. Sorry if i posted wrongly. 

There is no solution for my question there. 
There was entirely different topic with comparing 2 the same structured tables.

Here i am trying to get the list of all columns and if the column is not there, change Inner Join to catch it.

For example, 
I want to get "Key" and "Key2" columns from table. 

So i am checking first if TableCointains the columns and then selecting columns and using them in inner join. 
Are you sure i should go there?

Best,
Jacek

 
Posted : 09/06/2021 6:13 am
(@catalinb)
Posts: 1937
Member Admin
 

Yes, it's all there. Remember you asked about KeyList, that argument takes the list of keys used in the merge, you said there can be different number of keys for merging, one table can have 1 key, one table can have multiple keys.

 
Posted : 09/06/2021 6:26 am
Share: