Forum Discussion
Sorting by two things in table
- 7 years ago
Anonymous,
Table can be sorted by multiple columns, but I'm afraid this can only be achieved in power query. In power query, click advanced editor using M code like below:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfILDgeSJkCcn5eqFKsDEQ30cQGShkBcUp4PFw1xDAaSRiDRjKJUiGonuBnGSGaARMM8naEmw8xwhqs1RVLrDLcPXS3EPjOEfbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Item = _t, state = _t, Cost = _t, Supplier = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"state", type text}, {"Cost", Int64.Type}, {"Supplier", type text}}), Result = Table.Sort(#"Changed Type",{{"Item", Order.Ascending}, {"Cost", Order.Descending}}) in ResultCommunity Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous,
Table can be sorted by multiple columns, but I'm afraid this can only be achieved in power query. In power query, click advanced editor using M code like below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfILDgeSJkCcn5eqFKsDEQ30cQGShkBcUp4PFw1xDAaSRiDRjKJUiGonuBnGSGaARMM8naEmw8xwhqs1RVLrDLcPXS3EPjOEfbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Item = _t, state = _t, Cost = _t, Supplier = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"state", type text}, {"Cost", Int64.Type}, {"Supplier", type text}}),
Result = Table.Sort(#"Changed Type",{{"Item", Order.Ascending}, {"Cost", Order.Descending}})
in
Result
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous7 years agoNot applicable
May I clarify that when you say power query do you mean query editor within PowerBI?
- v-yuta-msft7 years agoCommunity Support
Anonymous,
Yes, the code I've put is in query editor.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.