Forum Discussion
SebSchoon1
Post Patron
4 years agoDynamic reordering of columns
Hi Guys,
I would like to know if it is possible to reorder columns dynamically?
I have all these orders corresponding to different "Types" of items which have different sizes accross the tables.
I would like to keep the columns which are the same in the same order. and concerning the other columns (the sizes)
To be arranged like the initial order in the tables.
Any way to achieve this?
Here are examples of how you can dynamically set the column order. If you can provide an example/screenshots of what the size column names are and the outcome you are trying to achieve I can provide a more specific solution.
Match the column order for a different table:
Table.SelectColumns ( #"Name of Previous Step", Table.ColumnNames ( #"Other Table Name" ) )Columns without "Size" in the name followed by columns with "Size" in the name:
Table.SelectColumns ( #"Name of Previous Step", let varBufferedList = List.Buffer ( Table.ColumnNames ( #"Name of Previous Step" ) ), varColumnsWithoutSize = List.Select ( varBufferedList, each not Text.Contains ( _, "Size" ) ), varColumnsWithSize = List.Select ( varBufferedList, each Text.Contains ( _, "Size" ) ), varFinalColumns = List.Combine ( {varColumnsWithoutSize, varColumnsWithSize} ) in varFinalColumns )