Forum Discussion

BiBra's avatar
BiBra
Icon for Helper III rankHelper III
8 years ago
Solved

Unpivot columns in table created from DAX epression

Hello I have created a table using a DAX expression. This table contains columns I want to be unpivoted. I there a way to do this?  The reason for using this expression, rather than a normal create...
  • v-yulgu-msft's avatar
    v-yulgu-msft
    8 years ago

    Hi BiBra,

     

    Based on above table, to get the latest date for each "target name", please try below M code:

     

    #"Grouped Rows" = Table.Group(#"Previous Step", {"target name"}, {{"AllRows", each _, Value.Type(#"Previous Step")}, {"Latest Date", each List.Max([date]), type number}}), 
    #"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"date", "product1", "product2", "product3"}, {"AllRows.date", "AllRows.product1", "AllRows.product2", "AllRows.product3"})

     

    Then, you can unpivot this table to a new structure.

     

    Regards,

    Yuliana Gu