Forum Discussion

pect's avatar
pect
Helper I
8 years ago
Solved

Table transformation

Hello everybody,   I would like to transform the following table:   Contracte Tipus contracte Contractació any 2017 Adjudicat any 2017 Contractació any 2018 Adjudicat any 2018 1 A 10...
  • MarcelBeug's avatar
    8 years ago

    Select the first 2 columns, unpivot other columns.

    Adjust the generated code with regard to the names of the new columns.

    Split the Estat column with custom delimiter " any ".
    Adjust both lines of the generated code with regard to the names of the new columns.

     

     

    let
        Source = Table3,
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Contracte", "Tipus contracte"}, "Estat", "Import"),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Estat", Splitter.SplitTextByDelimiter(" any ", QuoteStyle.Csv), {"Estat", "Any"}),
        #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Estat", type text}, {"Any", Int64.Type}})
    in
        #"Changed Type"