Forum Discussion
How to append only specified columns?
Actually you can't select columns during the append step, but you can select prior to, or after, the append.
What I meant, is that you can either:
- remove unwanted columns (select the columns, right-click and choose "Remove", resulting in code using Table.RemoveColumns), or
- select required columns (select the columns, righ-click and choose "Remove Other Columns", resulting in code using Table,SelectColumns).
In below example, from Source table with columns1-10, columns1-3 result after selection/removal:
let
Source = #table(10,{{1..10}}),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Column1", "Column2", "Column3"}),
#"Removed Columns" = Table.RemoveColumns(Source,{"Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10"})
in
#"Removed Columns"
So I was reacting to "I have manually deleted the unnecessary columns after the append" with the intention to state that you don't need to indicate which columns must be deleted; instead you can also indicate which columns need to be kept.
It was not my intention to state that you would be able to select columns during the append step; you can't.
You can specify specific colums during the Append step using Table.SelectColumns, as in:
Table.Combine({#"Query 1", Table.SelectColumns(#"Query 2", "Column Name")})
- isThisABug5 years agoFrequent Visitor
Hello BradZehr,
I had the same issue. I followed the same logic that your script has, but I didn't know how to write it. As far as I understand Power Query this is the most efficient way to do what Anonymous wanted to achieve. Thank you for your help! Already implemented your code and works perfectly 😄
Super kudo for you 👍
- mhdilyas20083 years agoFrequent Visitor
can you please give example here
fatcing the specific column data from multiple tables
- BradZehr3 years agoAdvocate II
To append selected columns from two tables:
= Table.Combine({Source, Table.SelectColumns(#"Table 1", "Column 1"), Table.SelectColumns(#"Table 2", "Column 2")})- mhdilyas20083 years agoFrequent Visitor
is this correct?
- BradZehr3 years agoAdvocate II
= Table.Combine({Source, Table.SelectColumns(#"TableName", {"Column 1", "Column 2"})})- BradZehr3 years agoAdvocate II
Sorry, that was multiple columns from the same table.