Forum Discussion

amied's avatar
amied
Frequent Visitor
6 months ago
Solved

Unpivoting data from Survey Monkey

Hi all,   I am importing data from Survey Monkey. For each question in my survey, there is a comment field as well, so I end up with data in the form:   ID Q1 Q1 comment Q2 Q2 comment 1...
  • Natarajan_M's avatar
    6 months ago

    Hi amied , 

    I have recreated the scenario using the sample data provided can you confirm is this what you are expecting ?

    input : 



    op :



    :

    let
        Source = Table,
        Unpivoted = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
        AddType = Table.AddColumn(Unpivoted, "Type", each 
            if Text.Contains([Attribute], "comment") then "Comment" else "Answer"),
        AddQuestion = Table.AddColumn(AddType, "Question", each 
            Text.BeforeDelimiter([Attribute], " ")),
        RemoveAttr = Table.RemoveColumns(AddQuestion, {"Attribute"}),
        Pivoted = Table.Pivot(
            RemoveAttr,
            List.Distinct(RemoveAttr[Type]),
            "Type",
            "Value"
        )
    in
        Pivoted


    Thanks .
    If this response was helpful in any way, I’d gladly accept a kudo.
    Please mark it as the correct solution. It helps other community members find their way faster