Forum Discussion

Nofunworking's avatar
Nofunworking
New Member
1 year ago
Solved

Splitting rows dynamically into tables

Hi all I came across with this tricky raw data and would see if anyone can help me with cleaning this data, I have a spreadsheet of transactions listed with multiple currencies altogether back to bac...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi,

    Thanks for the solution Omid_Motamedise  and lbendlin  provided, and i want to offer some more infotmation for user to refer to.

    hello Nofunworking , you can refet to the following sample.

    Create the following m code to change the table to the the following format.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSi4tKkrNS640VIrViVYqKUrMK05MLsnMz8vMS8vHKmiETdAYm6AJWBBmA1Z9VLUBqxLKbYgFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Column1],"currency") then [Column1] else null),
        #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
        #"Grouped Rows" = Table.Group(#"Filled Down", {"Custom"}, {{"Data", each Table.SelectColumns(_,{"Column1"}), type table}})
    in
        #"Grouped Rows"

     

    Then create a query to set it as a function.

    (a as text) =>
    let 
      _Filter= Table.SelectRows(Query1,each [Custom]=a)[Data]{0}
    in
        _Filter

    Then in this function, input the currency, such as 'currency1'

    Then it will generate a new table.

    You can use this way to split these rows to tables.

     

    Best Regards!

    Yolo Zhu

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