Forum

How to remove colum...
 
Notifications
Clear all

How to remove columns from list

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

ok,

thanks.

I have TableList query like here:

let
Source = Excel.CurrentWorkbook(){[Name="TableList"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TableName", type text}, {"ColumnName", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"TableName"}, {{"Table", each _, type table [TableName=nullable text, ColumnName=nullable text]}}),
#"List" = Table.AddColumn(#"Grouped Rows", "List", each Table.Column(

,"ColumnName"))
in
List

as you can see i am getting a List of columns for each table here

Next i have fnGetColumnsToKeep function where i am just filtering Table to get proper list:

(TableName)=>
let
Source = TableList,
#"Filter" = Table.SelectRows(Source, each ([TableName] = TableName))
in
#"Filter"

And i finally did it!:

let
Source = Table1,
TableName = "Table1",
ColumnsToKeep = Table.Column(fnGetColumnsToKeep(TableName), "List"){0},
LastShape = Table.SelectColumns(Source, ColumnsToKeep)
in
LastShape

the problem was with the source which i didnt have. I had only STRING "Table1".

Just a question, it is possbile to make the source and use string? 

Something like TableSourceName = Evaluate("Table1") and get table from string?

Best,
Jacek

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

See post 8 above, I already gave you the answer:

TableName="Table1"
Source= Excel.CurrentWorkbook(){[Name=TableName]}[Content] --> this returns a table based on the table name.

But this is a basic thing, you get this code from ANY query from a table.

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

Thank you very much for help Catalin,

Best !
Jacek

 
Posted : 09/06/2021 6:22 am
Page 2 / 2
Share: