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
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
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.