Forum Discussion

Steve_AAA's avatar
Steve_AAA
Frequent Visitor
2 years ago

Unpivot Suvey Data from SharePoint List

I have a SharePoint list that has containing survey data - columns like person filling in the survey (Microsoft Form), the date and details. I have a column for each question answer and question comment e.g.

 

NameDateQuestion 1 AnswerQuestion 1 CommentsQuestion 2 AnswerQuestion 2 CommentsQuestion 3 AnswerQuestion 3 CommentsQuestion 4 AnswerQuestion 4 Comments
Mickey Mouse04/10/23Yesexample comment goes here100This area could be better10n/aYesthis is brilliant
Donald Duck25/12/2022No 50sometimes1room for improvementNothis could be better

 

 

How can I unpivot this so that I get a line per question, with an answer and comment column?

 

NameDateQuestionAnswerComment
Mickey Mouse04/10/2023Question 1Yesexample comment goes here
Mickey Mouse04/10/2023Question 2100This area could be better
Mickey Mouse04/10/2023Question 310n/a
Mickey Mouse04/10/2023Question 4Yesthis is brilliant
Donald Duck25/12/2022Question 1No 
Donald Duck25/12/2022Question 250sometimes
Donald Duck25/12/2022Question 31room for improvement
Donald Duck25/12/2022Question 4Nothis could be better

5 Replies

  • mlsx4's avatar
    mlsx4
    Memorable Member

    Hi Steve_AAA 

     

    Assuming your data is in this way (it is not very clear in your explanation):

    You just have to select Type column and go to Transform > Pivot column

    And then, you pivot over Answer and in advanced options: not summarize

    • Steve_AAA's avatar
      Steve_AAA
      Frequent Visitor

      I've amended my original message to make things clearer. I currently have one row per survey response, but I want to have a row per question of the survey response, with a question, answer and comment column for each. I am using the unpivot function for just question and answer at the moment, but there is a new requirement to add comment to each line, so I am trying to amend the logic. 

      • mlsx4's avatar
        mlsx4
        Memorable Member

        Okey, Steve_AAA I have it clearer now.

         

        Then you need to include previous steps to the ones I have told you before.

         

        1) Select Name and date and unpivot other columns

        2) You will get two columns called Attribute and Value

        3) Split Attribute by delimeter (space) but the most on the right

        4) Rename your columns to Question, Type and Value

        5) Then, Pivot column as I told you before.

         

        If you have some doubt, please write me back

  • christinepayton's avatar
    christinepayton
    Most Valuable Professional

    Hold control and select the first two columns, right click, then "unpivot other columns". Then split the "Attribute" column on something that will split that last word into its own column (the answer/comment word) - I split on number of characters, since the position is always in the same place in the example. 

     

    That will put the question number in one column and Answer/Comment label in another. Then Pivot that Answer/Comment column again, choosing "do not aggregate" under advanced and the values column for the values dropdown. That will make Answer/Comment into separate columns and pivot the values under them: