Forum Discussion

Elliott's avatar
Elliott
Advocate II
10 years ago
Solved

Working with Separate Columns for Date

Hello All,   Back to basics for me on this one! :smileyfrustrated:   Using BI for a while now and have created plenty of reports, most of which I have been using SQL data, which appears to be ver...
  • Greg_Deckler's avatar
    10 years ago

    With your example, try unpivoting the date columns, like this:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEyNAASxgZKsTrRSv5FiXnpcEEjiGBAamIRhAcWBwk5JeYBIbJgLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"1/1/2016" = _t, #"2/1/2016" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"1/1/2016", Int64.Type}, {"2/1/2016", Int64.Type}}),
        #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"(blank)", "Fruit"}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Renamed Columns", {"Fruit"}, "Attribute", "Value")
    in
        #"Unpivoted Columns"

     

    You should end up with a table like:

     

  • Greg_Deckler's avatar
    Greg_Deckler
    10 years ago

    You don't have to write the "M" code, just select your date columns (all of them) and right click and choose "Unpivot Columns"