Forum Discussion
SebSchoon1
4 years agoPost Patron
Dynamic 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
4 years agoSuper User
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 )
SebSchoon1
4 years agoPost Patron
Hello, many thanks for the tip!!