I have a table containing a column called "Type" and I want to sort the rows of the table differently based on the value in that column. For example,
if Type = "A" then sort by {{"Column1", Sort.Ascending}, {"Column2", Sort.Ascending}}
if Type = "B" then sort by {{"Column3", Sort.Ascending}, {"Column4", Sort.Ascending}}
Is this possible to do? I tried this (assuming in this example that possible values in Type are only A and B)
This gives me an error: Expression.Error: We cannot apply operator < to types List and List.
My alternative was to split the table into two based on Type, sort those tables, then append. That feels rather messy if it's possible to do this in one step using Table.Sort but I am not sure if it's possible.
Thanks
if Type = "A" then sort by {{"Column1", Sort.Ascending}, {"Column2", Sort.Ascending}}
if Type = "B" then sort by {{"Column3", Sort.Ascending}, {"Column4", Sort.Ascending}}
Is this possible to do? I tried this (assuming in this example that possible values in Type are only A and B)
Code:
Table.Sort(MyTable, each if [Type] = "A" then {{"Column1", Sort.Ascending}, {"Column2", Sort.Ascending}} else {{"Column3", Sort.Ascending}, {"Column4", Sort.Ascending}})
This gives me an error: Expression.Error: We cannot apply operator < to types List and List.
My alternative was to split the table into two based on Type, sort those tables, then append. That feels rather messy if it's possible to do this in one step using Table.Sort but I am not sure if it's possible.
Thanks