Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
MSuser5
Helper III
Helper III

converting rows into column in powerquery

Hi All,

I have source data which is contain row level process step and i need to split into column level data in edit query transformation level.

ex: source file

1.PNG

 

 

Expected result using edit query: (Process row steps (input,reject,input2,review,review2,print)  need to convert into column level with IN and OUT time)

result:

2.PNG

thanks,

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @MSuser5 ,

 

Here are the steps you can follow:

1. Go to Power Query check [IN], [Out] Unpivot Columns.

vyangliumsft_0-1670912745493.png

Result:

vyangliumsft_1-1670912745496.png

2. Transform – Group  -- [ID] – Operation:All Rows.

vyangliumsft_2-1670912745499.png

3. Add Column – Custom Column – Enter the following code.

Table.AddIndexColumn([Count],"Rank",1,1)

vyangliumsft_3-1670912745501.png

4. Selected [Count] – Remove.

vyangliumsft_4-1670912745502.png

5. Expand [Custom] - Do not select column [ID] - OK.

vyangliumsft_5-1670912745504.png

6. Select the three columns [Custom.Process], [Custom.Attribute], [Custom.Rank] -- right mouse button in the Merge Column interface to set the information at the yellow label.

vyangliumsft_6-1670912745506.png

7. Select [Merged] -- Transform Pivot Column.

Value Column  --  [Custom.Value].

Advanced options Dont Aggregate.

vyangliumsft_7-1670912745510.png

8. Result:

vyangliumsft_8-1670912745511.png

 

Best Regards,

Liu Yang

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

View solution in original post

8 REPLIES 8
v-yangliu-msft
Community Support
Community Support

Hi  @MSuser5 ,

 

Here are the steps you can follow:

1. Go to Power Query check [IN], [Out] Unpivot Columns.

vyangliumsft_0-1670912745493.png

Result:

vyangliumsft_1-1670912745496.png

2. Transform – Group  -- [ID] – Operation:All Rows.

vyangliumsft_2-1670912745499.png

3. Add Column – Custom Column – Enter the following code.

Table.AddIndexColumn([Count],"Rank",1,1)

vyangliumsft_3-1670912745501.png

4. Selected [Count] – Remove.

vyangliumsft_4-1670912745502.png

5. Expand [Custom] - Do not select column [ID] - OK.

vyangliumsft_5-1670912745504.png

6. Select the three columns [Custom.Process], [Custom.Attribute], [Custom.Rank] -- right mouse button in the Merge Column interface to set the information at the yellow label.

vyangliumsft_6-1670912745506.png

7. Select [Merged] -- Transform Pivot Column.

Value Column  --  [Custom.Value].

Advanced options Dont Aggregate.

vyangliumsft_7-1670912745510.png

8. Result:

vyangliumsft_8-1670912745511.png

 

Best Regards,

Liu Yang

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

Hi,

 

This is really helpful - I have a follow up requirement though and wanted to ask thoughts on this! If you wanted the number appended on to the new columns to be more consistent (i.e. IN 1, OUT 1, IN 2, OUT 2) how would you do this without going through and manually renaming columns (as your number of columns is dynamic)?

 

Many thanks! 😊

Great, thanks

Hi @v-yangliu-msft,

 

Great it's working now as expected ..

Thanks,

MS

 

v-yangliu-msft
Community Support
Community Support

Hi @MSuser5 ,

 

Here are the steps you can follow:

1. Go to Power Query – check [IN], [Out] – Unpivot Columns.

vyangliumsft_0-1670828770613.png

Result:

vyangliumsft_1-1670828770615.png

2. Add Column – Index Column – From 1.

vyangliumsft_2-1670828770617.png

3. Select the three columns [Process], [Attribute], [Index] -- right mouse button – in the Merge Column interface – to set the information at the yellow label.

vyangliumsft_3-1670828770618.png

4. Select [Merged] -- Transform – Pivot Column.

Value Column  --  [Value].

Advanced options – Don’t Aggregate.

vyangliumsft_4-1670828770622.png

5. Result:

vyangliumsft_5-1670828770623.png

 

Best Regards,

Liu Yang

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

Hi @v-yangliu-msft ,

 

when we have bulk data index creating till the values ... its not getting appending the ID level data attached sample test file kindly check and suggest how to achive only process level should be 6 columns only.

 

PBIX file https://drive.google.com/file/d/15FZYD9A0dq-PJwFfpNRi1qMeA9AF2lZE/view?usp=sharing 

 

i have around 100 ID records hence it's generating 100 process level columns.

but it should be only 6 columns 

 

Thanks

Based on your sample data, which six columns would you expect to see?

lbendlin
Super User
Super User

Please do not do that. It is the opposite of what Power BI is about.  You can easily show the data in a matrix visual like that (although I would also recommend you reconsider) but please don't do that.  Quite the opposite, you should unpivot your data even more 

 

ID |  Process |  Type |  Date

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.