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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jcramb
Frequent Visitor

Power Query copy columns to new table

In Excel Power Query i have a table has columns of data that i need to stack into a new table.

 

Below is the original table.

Table that need to be transformedTable that need to be transformed

I Need a new table that copies that data column in

Columns P6 Activity ID, Bridge #, P6 Discipline Code, Description, Resource 1, Quantity 1 and puts into a new table.

Then copies that data column in

Columns P6 Activity ID, Bridge #, P6 Discipline Code, Description, Resource 2, Quantity 2 and put it below the data copied above

Then copies that data column in

Columns P6 Activity ID, Bridge #, P6 Discipline Code, Description, Resource 3, Quantity 3 and put it below the data copied above

Then copies that data column in

Columns P6 Activity ID, Bridge #, P6 Discipline Code, Description, Resource 4, Quantity 4 and put it below the data copied above

Then copies that data column in

Columns P6 Activity ID, Bridge #, P6 Discipline Code, Description, Resource 4, Quantity 4 and put it below the data copied above..

 

Does anyone one how to do this in Power Query?

 

Thanks For the Help

 

 

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

Hi @Jcramb 

Use Edit queries in Power BI Desktop

For this test data

NUM ID Bridge p6 description duration bud mahour forecast resource1 quantity1 resource2 quantity2 resource3 quantity3
1 1 a 1 as 1 1 1 a1 aa1 a2 aa2 a3 aa3
2 2 b 2 bd 1 1 1 b1 bb1 b2 bb2 b3 bb3
3 3 c 3 ce 1 1 1 c1 cc1 c2 cc2 c3 cc3
4 4 d 4 dw 1 1 1 d1 dd1 d2 dd2 d3 dd3

 

1.select columns from "Resource 1", "Quantity 1" to "Resource 3", "Quantity 3",

then select "Unpivot columns"

after this step, it generate new columns "Attribute" and "Value"

 

2.split column "Attribute" to two columns "Attribute.1" and "Attribute.2"

9.png

 

3.select "Attribute.1" and "Value: columns, then select "Pivot columns"

 

4.remove columns you don't need

finally, i get table as below

11.png

 

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
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

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @Jcramb 

Is this problem sloved?

If not, please let me know.

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-juanli-msft
Community Support
Community Support

Hi @Jcramb 

Use Edit queries in Power BI Desktop

For this test data

NUM ID Bridge p6 description duration bud mahour forecast resource1 quantity1 resource2 quantity2 resource3 quantity3
1 1 a 1 as 1 1 1 a1 aa1 a2 aa2 a3 aa3
2 2 b 2 bd 1 1 1 b1 bb1 b2 bb2 b3 bb3
3 3 c 3 ce 1 1 1 c1 cc1 c2 cc2 c3 cc3
4 4 d 4 dw 1 1 1 d1 dd1 d2 dd2 d3 dd3

 

1.select columns from "Resource 1", "Quantity 1" to "Resource 3", "Quantity 3",

then select "Unpivot columns"

after this step, it generate new columns "Attribute" and "Value"

 

2.split column "Attribute" to two columns "Attribute.1" and "Attribute.2"

9.png

 

3.select "Attribute.1" and "Value: columns, then select "Pivot columns"

 

4.remove columns you don't need

finally, i get table as below

11.png

 

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-juanli-msft
Community Support
Community Support

Hi @Jcramb 

It will take a long time to reproduce your data, and i'm not clear with the result table.

Could you copy the data from excel and paste here?

Also, enter column header and some example data in excel to show the expected result table?

 

Best Regards

Maggie

 

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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