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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

sort unpivot attributes by question order

Hello,

 

I am dealing with survey data (Questions and Answers). My particular problem is sorting the questions in order after unpivoting.

When I unpivot all the questions they get placed in a new column called "attributes" and the loose their question in order. I would like to change this so that in the graph they are in order from 1 to the last question. I tried doing something like adding a new table with the questions and a order # with a relation but that didnt work for me. Is there a way to achieve something like this? 

 

Questions graph(Stacked bar):  (Not correct order)

Questions graph.png

 

Un-ordered Questions example:

This is the way the questions get put in the attributes column after unpivoting

UnOrderQuestions.png

 

I would like change the order to this: 

 

Correct Order.png

 

 1 - Question1
2 - Questio2 

 

etc. 

 

Thank you! 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I figured it out. The values quere different from each other in the relational table and that is why ti wasn't working. 

 

Thanks for the help! 

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

You could use Sort by column in Power BI Desktop to achieve your requirement.

Before it, you need to add an index column for attributes column by your logic.

 

Best Regards,

Lin

 

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

@v-lili6-msft Thanks for the suggestion. 

 

I have created an index column and attempted to sort by that order but it doesn't work as intended. What it does it assigns a duplicate numbers to the answer rows and that is making the order wrong. I also tried to use the related table with just the answers and a index column and that does not work ether. Any other ideas?

 

Here is how the data is being ordered: 

 

QuestionOrder.PNG

 

Thanks again.

 

Anonymous
Not applicable

I figured it out. The values quere different from each other in the relational table and that is why ti wasn't working. 

 

Thanks for the help! 

What did you do to sort the mixed data types? Could you please state the solution? I am having the same issue here. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.