Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to migrate data

Hello all   I first want to say that I am a complete beginner at this. Any and all advice and/or external reading material you can give me is greatly appreciated.   So I have been given data that...
  • Jimmy801's avatar
    5 years ago

    Hello Anonymous 

     

    first of all you need to normalize your sharepoint lists. It means that the information of your bin is not in a column, but in a column name, or am I wrong? This probably can be achieved by using a Table.Unpivot. After that you have also to add a new column that identifies your list-name (plant information). Maybe some filtering is also needed, depending if your list contains also oder data and you need to find only the last version. After that you can combine your 5 transformed table into 1 table. Here a short example of a possible normalization, but without any knowledge of your data, it's not possible to make any serious proposal. 

    This code was generated only by using the GUI, so it was not even needed to write m-code.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTSMzDUMzJQ0lFyBGJTKG2hFKsDlDRGkTREYoClEXqdwKIwloWBAbp+kLCpAZJSoIpYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"BINA - Product" = _t, #"BINA - Quantity" = _t, #"BINB - Product" = _t, #"BINB - Quantity" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date",type date}, {"BINA - Product", type text}, {"BINA - Quantity", Int64.Type}, {"BINB - Product", type text}, {"BINB - Quantity", Int64.Type}}, "de-DE"),
        FilterForLastDayIfNeeded = Table.SelectRows(#"Changed Type", let latest = List.Max(#"Changed Type"[Date]) in each [Date] = latest),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(FilterForLastDayIfNeeded, {"Date"}, "Attribute", "Value"),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" - "}, QuoteStyle.Csv, false), {"Attribute.1", "Attribute.2"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type1", "Product", each if [Attribute.2]="Product" then [Value] else null),
        #"Filled Down" = Table.FillDown(#"Added Custom",{"Product"}),
        #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Attribute.2] = "Quantity")),
        #"Renamed Columns1" = Table.RenameColumns(#"Filtered Rows",{{"Value", "Quantity"}, {"Attribute.1", "BIN"}}),
        #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns1",{"Attribute.2"})
    in
        #"Removed Columns"

    Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy