Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Dynamic Transformation of Column Values to Column Names

Hi everyone,

I had the following problem

 

Considering I have the following table,

Ord_numCust_nameDatesDate Values
1111ABCOrder Date05/01/2021
1111ABCShipped Date05/03/2021
1111ABCDelivered Date05/05/2021

 

I wanted the following table from the above table,

Ord_numCust_nameOrder_dateShipped_dateDelivered Date
1111ABC05/01/202105/03/202105/05/2021

 

How do I transform into this?

 

Any help would be appreciated.

 

Thanks in advance.

  • Hi Anonymous ,

     

    You can use IU to do it, select the last two columns and click pivot columns:

     

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

     

    Best Regards,

    Dedmon Dai

     

     

2 Replies

  • Hi,

    This M code works

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ord_num", Int64.Type}, {"Cust_name", type text}, {"Dates", type text}, {"Date Values", type date}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Dates]), "Dates", "Date Values")
    in
        #"Pivoted Column"

    Hope this helps.

  • v-deddai1-msft's avatar
    v-deddai1-msft
    Community Support

    Hi Anonymous ,

     

    You can use IU to do it, select the last two columns and click pivot columns:

     

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

     

    Best Regards,

    Dedmon Dai