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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Sorting by Column with Duplicate Values

Got a dilema ..... in following some directions for sorting a Trade column, i ran into an error due to duplicates.  So i followed some instructions of adding a Index column (because the Trade column automatically puts things in alphabetical order), but i got an error and it is related to 2 sets of duplicates.   Im not sure how to handle it.  Again my goal is i want to be able to sort by column (index) which is the order of items that i want to show in my report vs alphabetical.

 

cnorris3570_1-1649389109526.png

 

im not sure what to do here.  How can i sortbycolumn if i getting error related to this duplicates?????  i dont want to remove the second set as it is a subset (spaced in some.....).  Can PBI even handle subsets like this??

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If the duplicates are subsets of the trade above them, you need to combine their father trade with them to make it clear which father trade they belong to. And this will create unique values for them. Use this new column in your report to display. 

vjingzhang_1-1649830764024.png

 

Transformation steps are as below. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsssSi3ISUxOLVaK1YlWCsgpzU3KzEvX9U4sKi5JzQMLKgBBUH5peoaupx9cIKQoMze/tATM9whzdNYNT83JTi0C811zUpNLijKTE3N0nYoS8zISc4kwJxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Trade = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Trade", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Trade", "Trade - Copy"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "Trade - Copy", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Trade - Copy.1", "Trade - Copy.2"}),
    #"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter","",null,Replacer.ReplaceValue,{"Trade - Copy.1"}),
    #"Filled Down" = Table.FillDown(#"Replaced Value",{"Trade - Copy.1"}),
    #"Added Custom" = Table.AddColumn(#"Filled Down", "Custom", each if [#"Trade - Copy.2"] = null then [#"Trade - Copy.1"] else [#"Trade - Copy.1"] & ": " & Text.Trim([#"Trade - Copy.2"]))
in
    #"Added Custom"

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If the duplicates are subsets of the trade above them, you need to combine their father trade with them to make it clear which father trade they belong to. And this will create unique values for them. Use this new column in your report to display. 

vjingzhang_1-1649830764024.png

 

Transformation steps are as below. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsssSi3ISUxOLVaK1YlWCsgpzU3KzEvX9U4sKi5JzQMLKgBBUH5peoaupx9cIKQoMze/tATM9whzdNYNT83JTi0C811zUpNLijKTE3N0nYoS8zISc4kwJxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Trade = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Trade", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Trade", "Trade - Copy"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "Trade - Copy", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Trade - Copy.1", "Trade - Copy.2"}),
    #"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter","",null,Replacer.ReplaceValue,{"Trade - Copy.1"}),
    #"Filled Down" = Table.FillDown(#"Replaced Value",{"Trade - Copy.1"}),
    #"Added Custom" = Table.AddColumn(#"Filled Down", "Custom", each if [#"Trade - Copy.2"] = null then [#"Trade - Copy.1"] else [#"Trade - Copy.1"] & ": " & Text.Trim([#"Trade - Copy.2"]))
in
    #"Added Custom"

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

lbendlin
Super User
Super User

you can either create a ragged hierarchy, or you can modify 34 and 35 to say "Plumbing-Karsten:Rough-IN" and "Plumbing-Karsten:Trimout"  (for example).

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.