Forum Discussion

han_rj's avatar
han_rj
Helper IV
4 months ago
Solved

remove duplicate value within a row

Hi Team,

 

Need help with a solution that can remove duplicate values within a row in column product.

 

Before

IDNameProductLocation

1

AbleCan;Tin;Tin;Can100
2SamCan;Pan;Pan;Can;Bin101
3SanPole;Bin;Pin;Bin102

 

After

IDNameProductLocation

1

AbleCan;Tin100
2SamCan;Pan;Bin101
3SanPan;Bin102
  • Add this line of code to your query

    = Table.TransformColumns(previousQueryStep, {{"Product", each Text.Combine(List.Distinct(Text.Split(_, ";")), ";"), type text}})

     

    Full example code

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJMykkFUs6JedYhmRAMZANFDA0MlGJ1opWMgOzgxFyomgAoBrGdMiHqDMHqjMHqQCIB+TmpIEnrgEyEIiOl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, Product = _t, Location = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"Product", type text}, {"Location", Int64.Type}}),
        Custom1 = Table.TransformColumns(#"Changed Type", {{"Product", each Text.Combine(List.Distinct(Text.Split(_, ";")), ";"), type text}})
    in
        Custom1

2 Replies

  • Add this line of code to your query

    = Table.TransformColumns(previousQueryStep, {{"Product", each Text.Combine(List.Distinct(Text.Split(_, ";")), ";"), type text}})

     

    Full example code

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJMykkFUs6JedYhmRAMZANFDA0MlGJ1opWMgOzgxFyomgAoBrGdMiHqDMHqjMHqQCIB+TmpIEnrgEyEIiOl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, Product = _t, Location = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"Product", type text}, {"Location", Int64.Type}}),
        Custom1 = Table.TransformColumns(#"Changed Type", {{"Product", each Text.Combine(List.Distinct(Text.Split(_, ";")), ";"), type text}})
    in
        Custom1
  • v-priyankata's avatar
    v-priyankata
    Community Support

    Hi han_rj 

    Thank you for reaching out to the Microsoft Fabric Forum Community.

    jgeddes Thanks for the inputs.

    I hope the information provided by user was helpful. If you still have questions, please don't hesitate to reach out to the community.