Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 ...
  • v-jingzhang's avatar
    4 years ago

    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. 

     

    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.