Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Dunkhan
New Member

Sort number as text from a list

Hi,


I'm trying to sort number separated by comma in descending order in a list.


I have a column of 3 number in text format, each separated by a comma

Capture d’écran 2021-09-09 193331.png
I would like to sort each numbers in each row by descending order.

I tried to transform the text and split them into number before sorting them, but i cannot find how to do that.

I also tried to transform them into a list, but i cannot find how to order the list.

listnumber.pnglist.png
How can i do that ??


(sorry for my english)

 
 
 
 
 
1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

Or maybe you want this...

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtWx0DFSitUBsYx1LMEsQx1TqJghUMwQzLLQMdAxhDENjXQMDZRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Custom" = Table.AddColumn(Source, "ListOfNumbers", each List.Sort( List.Transform(Text.Split([Column1],","), Number.From) , Order.Descending)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "BackToText", each Text.Combine(List.Transform( [ListOfNumbers], Text.From) ,",")) // This Step can be merged in single step with the previous one.
in
    #"Added Custom1"

Jakinta_0-1631213707923.png

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Since you already have them in a list column:


= Table.TransformColumns(TableName, {{"ListOfNumbers", each List.Sort}})

--Nate

 

Jakinta
Solution Sage
Solution Sage

Or maybe you want this...

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtWx0DFSitUBsYx1LMEsQx1TqJghUMwQzLLQMdAxhDENjXQMDZRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Custom" = Table.AddColumn(Source, "ListOfNumbers", each List.Sort( List.Transform(Text.Split([Column1],","), Number.From) , Order.Descending)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "BackToText", each Text.Combine(List.Transform( [ListOfNumbers], Text.From) ,",")) // This Step can be merged in single step with the previous one.
in
    #"Added Custom1"

Jakinta_0-1631213707923.png

 

That works !

Thank you so much 🙂

 
edhans
Super User
Super User

See if this helps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstAxNNIxNFSK1YlWMtEx07EEs4CixjrGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Sorted Rows" = Table.Sort(#"Split Column by Delimiter",{{"Column1.1", Order.Ascending}})
in
    #"Sorted Rows"

THis turn this:

edhans_0-1631213137289.png

 

into this:

edhans_1-1631213165991.png

 

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

That's not exactly the solution i was looking for, but thank you for taking the time to answer my question 🙂

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors