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

Sort order of Pivoted Columns in Data Table/Query left to right?

Hello - This forum is great, I have learned so much in the last few months from users here!

I'm relatively new to PowerBI, and iIf this topic already exists, I apologize, perhaps I was not using correct terminology when searching, but I couldn't find anything.

 

I am trying to create a particular view in a data table /query to mimic an output currently created by hand in Excel pivot. 

 

(I know how to do this in a visual, but can't get the visual to export in the same format I created, so I am using a Data Table instead because it can be copied & pasted into another Excel, PowerPoint, etc. in the same format)


I successfully copied my original table and grouped it by 2 fields (Line Type & 9Box), and then pivoted to move my Fiscal Year Week spend $ data into individual columns. However, there seems to be no option to select how those columns are ordered after the pivot. It automatically put them in DEscending order (newest week to oldest week column), but I would rather have oldest to newest, so that future week columns of spend data (when source data is refreshed) are correctly placed at the end/right of the data.

 

Is there any way I can force Power BI to Pivot the columns in a different order or sort the order AScending after my pivot? i.e start with column "FY20 01" and run to column "FY20 21" from left to right? 

 

Here's the synthax from the advanced editor if that is helpful:

#"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[#"Fiscal Calendar.Fiscal Week"]), "Fiscal Calendar.Fiscal Week", "PO Value by 9Box by Line Type"),

 

Any help would be appreciated, thanks.

 

V.

 

2 REPLIES 2
Nathaniel_C
Super User
Super User

@Vanessa_S ,

 

Maybe you could supply some data so that we might walk through your steps

 

You may want to read this post to get your question answered more quickly:

Get your questions answered quickly

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Nathaniel_C , thanks for the response. 

 

Here's some sample data - I'm looking to order column 3 to 23 in opposite order from FY20 1 to FY20 20 left to right.

[PO] Line Type9 Box BUFY20 21FY20 20FY20 19FY20 18FY20 17FY20 16FY20 15FY20 14FY20 13FY20 12FY20 11FY20 10FY20 09FY20 08FY20 07FY20 06FY20 05FY20 04FY20 03FY20 02FY20 01
Catalog ItemBU1 243124243124243124242
Catalog ItemBU2312423114243124243123
Catalog ItemBU3124243431424312424314
Catalog ItemBU4431312313121242313142
Catalog ItemBU5243124231123143124242
Non-Catalog ItemBU1 124243431424312424331
Non-Catalog ItemBU2243124243124243124242
Non-Catalog ItemBU3431312313121242313142
Non-Catalog ItemBU4243124243124242242434
Non-Catalog ItemBU5242434314212424312424

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.