Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

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)

 

Un-ordered Questions example:

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

 

I would like change the order to this: 

 

 

 1 - Question1
2 - Questio2 

 

etc. 

 

Thank you! 

  • Anonymous's avatar
    Anonymous
    7 years ago

    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! 

4 Replies

    • Anonymous's avatar
      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: 

       

       

      Thanks again.

       

      • Anonymous's avatar
        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!