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
TakaHom
New Member

Sorting columns of matrix on unpivot query

Hello everyone, I'm very beginner on BI. have a lot of trouble with it. Please help me!

 

I have a unpivoted query like following.

ID, Period, Number

1, 1, 3.4

1, 5, 2.4

1, 10, 5.3

1, Qtr, 5.5

1, YTD, 12

 

And the current matrix is following.

ID, 1, 10, 5, Qtr, YTD

1, 3.4, 5.3, 2.4, 5.5, 12

 

I’d like to create following. Please tell me how to do it!

ID, 1, 5, 10, Qtr, YTD

1, 3.4, 2.4, 5.3, 5.5, 12

OR

ID, Qtr, YTD, 1, 5, 10

1, 5.5, 12, 3.4, 2.4, 5.3

 

I imagine if I could set any dummy columns and hide them for ordering, I would be able to realize what I want to do….
Are there any good options?

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

Hi @TakaHom ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a sort table just as suggested by @lbendlin 

2. Create a matrix visual (Rows: ID   Columns: Period (from Sort table)  Values: Number)

3. Select the field Period in Sort table and navigate to Column tools, Sort by column: Order

Sorting columns of matrix on unpivot query.JPG

Best Regards

Community Support Team _ Rena
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-yiruan-msft
Community Support
Community Support

Hi @TakaHom ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a sort table just as suggested by @lbendlin 

2. Create a matrix visual (Rows: ID   Columns: Period (from Sort table)  Values: Number)

3. Select the field Period in Sort table and navigate to Column tools, Sort by column: Order

Sorting columns of matrix on unpivot query.JPG

Best Regards

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

Create a separate table that has an index column and the order you want the periods to appear in

 

1 1

2 5

3 10

4 QTR

5 YTD

 

Link that table into the data model (or merge it in Power Query) and then use the index column to sort the period column ("Sort by other column")

Thank you for your advice, but I could not solve my trouble. I think I could trace your advice completely. I could sort it’s rows by the table. But I'm sorry, what I want to do is to sort the columns after pivot data table. If I could specify the order of the columns of pivot table, I think the problem would be solved.
Thank you in advance.

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.