Forum Discussion
Sorting by size
- 4 years ago
Hi ChrisDg ,
Just as DataInsights mentioned before, you can create an Index column, then sort it by index.
Except the methods DataInsights mentioned before, you can also add Index columns in PQ:
Here is the M code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NYxBCoAwDAS/IrnaQjZtUV/gB7wVD4JHURD/j0msx5mdpFYCBRJaQyWJYAUMTkAshmVyLIjCPrdd2AIz4yeKCrAb+W6UvPE3aFGrzCX8GaNXztl5vrdz75br2Q6TSd+vLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Company size" = _t, #"Total Views" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Company size", type text}, {"Total Views", Int64.Type}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type), #"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Index"}), #"Added Index1" = Table.AddIndexColumn(#"Removed Columns", "Index", 1, 1, Int64.Type) in #"Added Index1"Then sort column by index:
Output:
Here is another method to achieve your goal:
Add Index to the tooltips field:
Then sort it:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ChrisDg ,
Just as DataInsights mentioned before, you can create an Index column, then sort it by index.
Except the methods DataInsights mentioned before, you can also add Index columns in PQ:
Here is the M code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NYxBCoAwDAS/IrnaQjZtUV/gB7wVD4JHURD/j0msx5mdpFYCBRJaQyWJYAUMTkAshmVyLIjCPrdd2AIz4yeKCrAb+W6UvPE3aFGrzCX8GaNXztl5vrdz75br2Q6TSd+vLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Company size" = _t, #"Total Views" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Company size", type text}, {"Total Views", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Index"}),
#"Added Index1" = Table.AddIndexColumn(#"Removed Columns", "Index", 1, 1, Int64.Type)
in
#"Added Index1"
Then sort column by index:
Output:
Here is another method to achieve your goal:
Add Index to the tooltips field:
Then sort it:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- ChrisDg4 years agoHelper I
Hi Jianbo Li,
Putting the index into the tooltips section worked for me. The visuals you sent were also extremely helpful.
Thank you!
Chris