Forum Discussion

pakovic's avatar
pakovic
Helper I
5 years ago
Solved

transform table

Hello everyone, thank you very much for reading my post. I am trying to transform this table.   I have a table with data that looks like this:   Is it possible to transform the table so tha...
  • v-henryk-mstf's avatar
    5 years ago

    Hi pakovic ,


    According to your needs, I did a test in power query, and the following results can be used as a reference:

    let
        Origen = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fVA9C8IwEP0rR+YKySWnrsVJqEZoFykdOhQUWhXs/8crNfXQmIwv795XXStnNT8DK9j5wyk/nsGoTKkmq5XfF0Baw9AzYpi1oBt6oxjQ6j62PZRt3z2hvFwfQ3cbgXWZY+XlJDOfUkyP0nL4N4gV4JIZBYj0KZKysExZB4qv8gLCQnIfFyjzJ4r5MDof2/9GsekobhqEIr1MdFBMq5E0FMW+s28nx+YF", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Description = _t, Euro = _t]),
        #"Tipo cambiado" = Table.TransformColumnTypes(Origen,{{"Description", type text}, {"Euro", Int64.Type}}),
        Custom1 = Table.SelectRows(#"Tipo cambiado",each Text.Start([Description],5)<>"TOTAL"),
        #"Added Custom" = Table.AddColumn(Custom1, "Customer", each if Text.Contains([Description], "COMPANY") then [Description] else null),
        #"Filled Down" = Table.FillDown(#"Added Custom",{"Customer"}),
        #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Euro] <> null)),
        Custom2 = Table.AddColumn(#"Filtered Rows", "Sales Shipment", each if Text.Contains([Description],"Sales Shipment")
    then [Description]
    else null),
        #"Filled Up" = Table.FillUp(Custom2,{"Sales Shipment"}),
        Custom3 = Table.SelectRows(#"Filled Up",each Text.Start([Description],5)<>"Total"),
        #"Reordered Columns" = Table.ReorderColumns(Custom3,{"Customer", "Sales Shipment", "Description", "Euro"}),
        #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Euro", "Item"}}),
        Custom4 = Table.TransformColumns(#"Renamed Columns",{"Sales Shipment",each Text.End(_,3)})
    in
        Custom4

     

    Here is the sample pbix file.


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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