Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Unpivot Data Model Table #7991

    Dan Bliss
    Participant
    • Started: 1
    • Replies: 1
    • Total: 2

    Hey BKaufman,

    You should not have any problem unpivoting the columns as you describe, so long as you have created a query within Power Query.  Perhaps you’ve done something somewhat different.  Loading a table to a data model will not affect the ability of PQ to unpivot the table.

    If you have done something like add a Calculated Column to a table loaded into your data model, and you want to unpivot the resultant table using PQ, you must first load the resultant table to a worksheet and create a new query based on the resultant table on a worksheet.  This is awkward and confusing, but I know of no way around it.  A naming convention that helps follow the trail of steps may help, such as:

    myTable, myTable_1, myTable_2, etc.

    Here is my result, after creating a table and query –  duplicating your described table schema & sample data:

    Date ID Category Rev COGS GM
    1/4/2017 1 NE 4230 3850 380
    3/6/2017 345 SW 3487 2483 1004
    4/8/2017 76 Central 784 874 -90
    5/2/2017 24 NE 329 123 206

    let
    Source = NotUnpivoted,
    #”Unpivoted Columns” = Table.UnpivotOtherColumns(Source, {“Date”, “ID”, “Category”}, “Attribute”, “Value”)
    in
    #”Unpivoted Columns”

    Date ID Category Attribute Value
    1/4/2017 0:00 1 NE Rev 4230
    1/4/2017 0:00 1 NE COGS 3850
    1/4/2017 0:00 1 NE GM 380
    3/6/2017 0:00 345 SW Rev 3487
    3/6/2017 0:00 345 SW COGS 2483
    3/6/2017 0:00 345 SW GM 1004
    4/8/2017 0:00 76 Central Rev 784
    4/8/2017 0:00 76 Central COGS 874
    4/8/2017 0:00 76 Central GM -90

    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)