Forum Discussion

Jase68's avatar
Jase68
Helper I
6 years ago
Solved

Transpose a table

Hi PBI Experts   I habe a simple table that I need to transpose so that the DATES (Year-Wk) move from the rows to the columns.   This is my current format;   Year-Week MeasureID Value 2020-01 ...
  • Greg_Deckler's avatar
    6 years ago

    Here is the Power Query version:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1MFTSUXIEYlOlWB2YmBFUzNAASRCk0AkkiK4SJGgEVBkLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Year-Week" = _t, MeasureID = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year-Week", type date}, {"MeasureID", type text}, {"Value", Int64.Type}}),
        #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Year-Week", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Year-Week", type text}}, "en-US")[#"Year-Week"]), "Year-Week", "Value", List.Sum)
    in
        #"Pivoted Column"
  • Anonymous's avatar
    Anonymous
    6 years ago

    Jase68 

    Query Editor => Pivot column

     

     

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

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Jase68  select the first two columns and pivot the value column in Power Query