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 th...
- 4 years ago
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 )
jennratten
Super User
4 years agoHello - yes, it is possible to dynamically reorder columns. When you say 'keep columns that are the same in the same order', do you mean that the tables in your list do not all have the same columns - or do you mean you'd like columns that have the same values to be in the same order? Are the size columns in the same table(s)? Where are they getting out of order? Can you share your script?