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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
GabrielN81
Regular Visitor

sorting numbered bullet points

Hi everyone, hoping someone can help on this.

I have a list of bullet points in a table visual such as the following: 1; 1.1; 1.2; 1.3 all the way through 1.13,

In ordering this list in the table, I get 1.10 before 1.2

How do I get it reordered so that 1.2 comes before 1.10? 

See screen capture:

2023-07-12 094401.png

 

Thanks!

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @GabrielN81 ,

 

I suggest you to create a [ID Order] column to sort your [ID] column.

Please refer to my M code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzVIrVAdFGUNoYSptAaVMobWgAY8B0GMK0GEL0GEHNMoKaZaQHFzeAMWAqQHpjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"ID", Order.Ascending}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Sorted Rows", "ID", "ID - Copy"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "ID - Copy", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"ID - Copy.1", "ID - Copy.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"ID - Copy.1", Int64.Type}, {"ID - Copy.2", Int64.Type}}),
    #"Duplicated Column1" = Table.DuplicateColumn(#"Changed Type1", "ID - Copy.2", "ID - Copy.2 - Copy"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Duplicated Column1",{{"ID - Copy.2 - Copy", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type2", "ID Order", each [#"ID - Copy.1"]*Number.Power(10,Text.Length([#"ID - Copy.2 - Copy"])) + [#"ID - Copy.2"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"ID - Copy.1", "ID - Copy.2", "ID - Copy.2 - Copy"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Removed Columns",{{"ID Order", Int64.Type}})
in
    #"Changed Type3"

New Table:

vrzhoumsft_1-1689845379335.png

Select [ID] column and sort it by [ID Order] in Column Tool. Result is as below.

vrzhoumsft_2-1689845401767.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @GabrielN81 ,

 

I suggest you to create a [ID Order] column to sort your [ID] column.

Please refer to my M code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzVIrVAdFGUNoYSptAaVMobWgAY8B0GMK0GEL0GEHNMoKaZaQHFzeAMWAqQHpjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"ID", Order.Ascending}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Sorted Rows", "ID", "ID - Copy"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "ID - Copy", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"ID - Copy.1", "ID - Copy.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"ID - Copy.1", Int64.Type}, {"ID - Copy.2", Int64.Type}}),
    #"Duplicated Column1" = Table.DuplicateColumn(#"Changed Type1", "ID - Copy.2", "ID - Copy.2 - Copy"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Duplicated Column1",{{"ID - Copy.2 - Copy", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type2", "ID Order", each [#"ID - Copy.1"]*Number.Power(10,Text.Length([#"ID - Copy.2 - Copy"])) + [#"ID - Copy.2"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"ID - Copy.1", "ID - Copy.2", "ID - Copy.2 - Copy"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Removed Columns",{{"ID Order", Int64.Type}})
in
    #"Changed Type3"

New Table:

vrzhoumsft_1-1689845379335.png

Select [ID] column and sort it by [ID Order] in Column Tool. Result is as below.

vrzhoumsft_2-1689845401767.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Idrissshatila
Super User
Super User

Hello @GabrielN81 ,

 

the 1.2 is being read as 1.20 thus its showing after 1.2.

 

so in order to show it before, then it should be 1.02 so it would show as u want.

 

but as sorting, it is working fine because its reading it as 1.20.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.