Forum Discussion

Tome_05's avatar
Tome_05
Helper III
1 year ago
Solved

How to display duplicate data

Thank you as always. The attached image shows the number "8" in a red box, but how can I display the data in that row as 8 duplicates? Please let me know.
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Tome_05 ,

     

    Thanks for reaching out to us.

    This is a common question, and it can be implemented in Power Query Editor.

    You can refer to the method in this post.

    powerquery - Power Query: Duplicate Rows Based on Value - Stack Overflow

    Here's the code:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJRitWJVnICsozALGcgy1gpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColA = _t, Stock = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ColA", type text}, {"Stock", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Col", each List.Repeat({[ColA]},[Stock])), //Adds a column with lists, repeating ColA based on Stock.
        #"Expanded Col" = Table.ExpandListColumn(#"Added Custom", "Col") //Expands the lists into individual rows.
    in
        #"Expanded Col"

    Or you can download my attachment for more details.

     

    Best Regards,
    Stephen Tao

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