Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Power Query

Hi All, Can someone help me with Pivote, I know there is a sequence for transpose/pivote/unpivot to have a single row.

 

example:

Data       
CodeMonth nameABCDEF
100janM11112131415
101janM22122232425
102febM33123242526
103febM14124252627
104marM25125262728
105marM16126272829
106aprilM37127282930
107aprilM58128293031
108janM79129303132
109febM910130313233
110marchM1111131323334

 

Expected Output Like this below:

 

 

 

  • Hi Anonymous ,

    According to your description, here's my solution.

    1.Select columns from A to F, then click Unpivot Columns.

    Result:

    2. To sort the month name column, add a custom column:

    if [Month name]="jan" then 1 else if [Month name]="feb" then 2 else if [Month name]="mar" then 3 else if [Month name]="april" then 4 else 5

    Sort Month name column by MonthNo column.

    In a matrix, put Code in Rows, Month name and Attribute in Columns, get the result:

    I attach my sample below for your reference.

     

    Best regards,

    Community Support Team_yanjiang

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

5 Replies

  • Hi Anonymous ,

    According to your description, here's my solution.

    1.Select columns from A to F, then click Unpivot Columns.

    Result:

    2. To sort the month name column, add a custom column:

    if [Month name]="jan" then 1 else if [Month name]="feb" then 2 else if [Month name]="mar" then 3 else if [Month name]="april" then 4 else 5

    Sort Month name column by MonthNo column.

    In a matrix, put Code in Rows, Month name and Attribute in Columns, get the result:

    I attach my sample below for your reference.

     

    Best regards,

    Community Support Team_yanjiang

    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
      Not applicable

      Thanks For your help .....

  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous in Excel pivot, just drop columns Months names and Product into Columns area. I hope this help

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi some_bih , Thanks for the reply,  Only we use Power Query Editor,,......i am giving some example data in excel...

  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous I do not understand your request. After creation of PQ transformation your output could be pivot table and then do as I described.