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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Andrew415
Frequent Visitor

Pivoting Multiple Columns More Efficiently

Hi, I am trying to find a more efficient way to multiple pivot columns in Power Query from a shipping report. I'm currently selecting each pair of columns (description and adjacent amount), pivoting the columns, and then removing the empty column from the pivoted pair.

 

A couple of my headaches with the raw data is

1) headers for the "tracking ID charge descriptions" and amounts are not static ("charge description_3" might say remote residential one week, and then fuel surcharge another week)

2) there are ~100 columns of "charge description" and "charge amount" that need to be paired together, and most will be completely null/empty

 

Data sample

Tracking IDDateTracking ID Charge DescriptionTracking ID Charge AmountTracking ID Charge Description_1Tracking ID Charge Amount_2Tracking ID Charge Description_3Tracking ID Charge Amount_4Tracking ID Charge Description_104Tracking ID Charge Amount_105Tracking ID Charge Description_106Tracking ID Charge Amount_107
1231/1/2025  Fuel Surcharge1.25Remote Residential15    
2341/7/2025  Fuel Surcharge3.4  Address Correction13.5  
3451/21/2025Extended Residential7Fuel Surcharge2.1  Address Correction13.5  
5671/28/2025  Fuel Surcharge4.5  Address Correction13.5  
4562/6/2025  Fuel Surcharge8.2Remote Residential15Address Correction13.5  
6782/12/2025  Fuel Surcharge2.4      
8902/19/2025  Fuel Surcharge1.3      
9012/27/2025Extended Residential7Fuel Surcharge6.5      

 

End-state

Tracking IDDateExtended ResidentialFuel SurchargeRemote ResidentialAddress Correction
1231/1/2025 1.2515 
2341/7/2025 3.4 13.5
3451/21/202572.1 13.5
5671/28/2025 4.5 13.5
4562/6/2025 8.21513.5
6782/12/2025 2.4  
8902/19/2025 1.3  
9012/27/202576.5  
1 ACCEPTED SOLUTION
SundarRaj
Super User
Super User

Hi @Andrew415 ,
With your source data, I came up with a solution in Power Query. Do have a look. Thanks!
https://docs.google.com/spreadsheets/d/1EIpZo5-DOpKhDYU4IMOfQYYtWdMh6sx7/export?format=xlsx&ouid=104...

Sundar Rajagopalan

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Andrew415,

As we haven’t heard back from you, we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @Andrew415,

As we haven’t heard back from you, we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Regards,
Vinay Pabbu

SundarRaj
Super User
Super User

Hi @Andrew415 ,
With your source data, I came up with a solution in Power Query. Do have a look. Thanks!
https://docs.google.com/spreadsheets/d/1EIpZo5-DOpKhDYU4IMOfQYYtWdMh6sx7/export?format=xlsx&ouid=104...

Sundar Rajagopalan

Thank you, this works perfectly for what I am trying to accomplish.

Andrew415
Frequent Visitor

Would it be possible to list the measure here as text? I'll give it a go and see if it might help. The blank columns wouldn't need to be part of the visual

hello @Andrew415 

 

i am not sure why you want it as text but perhaps it is possible.

you can tweak the DAX however you want to match up your requirement including the blank column.

 

otherwise, try using @SundarRaj 's solution. it surely gives your broader insight of your case.

 

Thank you.

Irwan
Super User
Super User

hello @Andrew415 

 

i dont know how many column you want to show in your visual.

if your visual only contain couple columns such as Extended Residential, Fuel Surcharge, Remote Residential, and Address Correction, maybe measure should be sufficient for those four instead of unpivoting ~100 columns.

Irwan_0-1748560522877.png

 

Hope this will help.

Thank you.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.