Hi all,
This should be easy but I'm having some trouble with the syntax. I'm trying to sort multiple columns in ascending order in my table. It's easy enough to manually click each column and sort it in descending order, but then my M-code is hard-coded to these column header names. If the header names change, the code will break.
Manually sorting each column:
I have a list that dynamically populates the correct headers. What is the correct way to write the statement below?
Dynamically sorting each column according to my list, HeaderstoSort:
This should be easy but I'm having some trouble with the syntax. I'm trying to sort multiple columns in ascending order in my table. It's easy enough to manually click each column and sort it in descending order, but then my M-code is hard-coded to these column header names. If the header names change, the code will break.
Manually sorting each column:
Power Query:
Table.Sort(PreviousStep,{{"Column1", Order.Ascending}, {"Column2", Order.Ascending}, {"Column3", Order.Ascending}, {"Column4", Order.Ascending}})
I have a list that dynamically populates the correct headers. What is the correct way to write the statement below?
Dynamically sorting each column according to my list, HeaderstoSort:
Power Query:
Table.Sort(PreviousStep,{HeaderstoSort, Order.Ascending})