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
John_C_
Regular Visitor

unpivot and append multiple columns

Hi everybody, 

 

hope, this is an interessting task for you. I got a bit stuck and hope, you can help me. 

 

I have a long table with many columns like this: 

 

  Access Line 1  Switch 1  Router  
CityBranche Monthly ChargesxxxxxxMonthly ChargesOne Time ChargexxxMonthly ChargesOne Time Charge
New York1500  50250 90260
New York2600  60260 90280
New York3500  50280 90260
Boston1600  50260 50270
Boston2500  50270 80250
Boston3600  50250 50230
Chicago1500  40230 80250
Chicago2600  60250 80250
Chicago3600  50250 50

300

 

In reality I have more than 20 objects like Access Line 1, 2, 3, 4, ... Switch 1, 2, 3, ... etc ... 

 

1. I would like to put the 1. Header "Access Line 1", "Switch", etc. into another column called "Object" 

2. I would like to put the "Monthly Charges" and "One Time Charges" into the column called "Charge" 

2. I would like to put the values into an column called "Value". 

 

My goal would be like this: 

City

Branche

Object

Charge

Value

New York

1

Access Line 1

Monthly Charges

500

New York

2

Access Line 1

Monthly Charges

600

New York

3

Access Line 1

Monthly Charges

500

Boston

1

Access Line 1

Monthly Charges

600

Boston

2

Access Line 1

Monthly Charges

500

Boston

3

Access Line 1

Monthly Charges

600

Chicago

1

Access Line 1

Monthly Charges

500

Chicago

2

Access Line 1

Monthly Charges

600

Chicago

3

Access Line 1

Monthly Charges

600

New York

1

Switch 1

Monthly Charges

50

New York

2

Switch 1

Monthly Charges

60

New York

3

Switch 1

Monthly Charges

50

Boston

1

Switch 1

Monthly Charges

50

Boston

2

Switch 1

Monthly Charges

50

Boston

3

Switch 1

Monthly Charges

50

Chicago

1

Switch 1

Monthly Charges

40

Chicago

2

Switch 1

Monthly Charges

60

Chicago

3

Switch 1

Monthly Charges

50

New York

1

Switch 1

One Time Charge

250

New York

2

Switch 1 

One Time Charge

260

New York

3

Switch 1

One Time Charge

280

Boston

1

Switch 1

One Time Charge

260

Boston

2

Switch 1

One Time Charge

270

Boston

3

Switch 1

One Time Charge

250

Chicago

1

Switch 1

One Time Charge

230

Chicago

2

Switch 1

One Time Charge

250

Chicago

3

Switch 1

One Time Charge

250

 

I could unpivot and append all the 30 columns manually. But is there a better solution like a for ... next - loop? 

 

Thanks a lot in advanced

John 

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

@John_C_,

 

You may take a look at the post below.

https://community.powerbi.com/t5/Desktop/Merged-Cells-in-Source/td-p/194473

Community Support Team _ Sam Zha
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

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@John_C_,

 

You may take a look at the post below.

https://community.powerbi.com/t5/Desktop/Merged-Cells-in-Source/td-p/194473

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

Hi Sam, 

 

awesome! You saved my day! Thanks a lot! 

 

John 

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.

Top Solution Authors