Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello Power BI community,
I am currently facing an issue while trying to create a pivot table in Power Query with unpivoted data. Specifically, I have three columns: EmployeeName, Year, and Count, in unpivoted order. My goal is to pivot this data while preserving the original sort order of the EmployeeName column and arranging the years in ascending order.
However, when I pivot the data by selecting the Year column, the EmployeeName order changes. I would greatly appreciate your assistance in achieving this objective while maintaining the initial sort order of the EmployeeName column and ensuring that the years are displayed in ascending order.
Your expertise and guidance on this matter would be invaluable to me. Thank you in advance for your time and assistance.
Best regards,
Qasim
Solved! Go to Solution.
Hi @Qasim_Jan ,
Before you perform your pivot step in Power Query, go to the Add Column tab > Index Column > From 1. This will index your table in the current sort order.
After you pivot , you can then sort by the index column and year to get the data in the exact order you want.
Pete
Proud to be a Datanaut!
Hi @Qasim_Jan ,
Before you perform your pivot step in Power Query, go to the Add Column tab > Index Column > From 1. This will index your table in the current sort order.
After you pivot , you can then sort by the index column and year to get the data in the exact order you want.
Pete
Proud to be a Datanaut!
Hi @BA_Pete ,
Your suggestion to add an index column before the pivot and then sorting by the index column and year was spot on. It worked like a charm!
Your expertise and willingness to assist are truly appreciated. Thank you once again for your prompt and effective help.
Best regards,
Qasim
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 8 | |
| 7 |