Forum Discussion
Dynamic reordering of columns
- 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 )
Hi SebSchoon1,
If the first table is already in the table you want.
a. Append tables with drill-down function:
1. Right-click on the header "Col" and select Drill Down
2. Add Text.Combine(Default step name). All tables will be appended according to the first table order.
If your first table required the headers to be promoted to the first rows.
1. Add a custom column: Table.PromoteHeaders([Col]).
2. do "a" above.
If the above solution is not what you are after. You can try the formula below.
1. Add a custom column: Table.ReorderColumns([Col], Table.ColumnNames(#"Previous Step Name"{0}[Col]))
Regards
KT