Forum Discussion

akoconnor's avatar
akoconnor
New Member
3 years ago

newbie transformation question

Hello!  New to PQ and I may not have the proper vocabulary to ask this, possibly, simple question.

 

I have been given data that is iteritive in rows. I know I need to transform it but everything I try is not quite right. In the data below, for each question I would like to have a seperate column, but only one row for Sofia and her answers in the correct column. Thoughts?

 

What I have:

NameQuestionAnswer
SofiaInstitution: - (MQ0194)UAB
SofiaDepartment/Division: - (MQ0195)Neurobiology
SofiaRegistrant type: - (MQ0196)Faculty: Instructor, Assistant Professor, Associate Professor, or Professor
SofiaPlease select your mentor from this list of Cancer Center Members: - (MQ0197)Sofia  NO
SofiaWill you be presenting a poster at this year's retreat? - (MQ0198)No
SatoruInstitution: - (MQ0194)UAB
SatoruDepartment/Division: - (MQ0195)Neurosurgery
SatoruRegistrant type: - (MQ0196)Faculty: Instructor, Assistant Professor, Associate Professor, or Professor
SatoruPlease select your mentor from this list of Cancer Center Members: - (MQ0197)Erwin  NO
SatoruWill you be presenting a poster at this year's retreat? - (MQ0198)No

 

What I want:

NameInstitution: - (MQ0194)Department/Division: - (MQ0195)Registrant type: - (MQ0196)Please select your mentor from this list of Cancer Center Members: - (MQ0197)Will you be presenting a poster at this year's retreat? - (MQ0198)
SofiaUABNeurobiologyFaculty: Instructor, Assistant Professor, Associate Professor, or ProfessorSofia  NO

No

 

SatoruUABNeurosurgeryFaculty: Instructor, Assistant Professor, Associate Professor, or ProfessorErwin NONo

 

1 Reply

  • This is a simple Pivot on the Question column with No Aggregation

    From the UI:

     

    Code from Advanced Editor

     

    let
    
    //Change next line to reflect actual data source
        Source = Excel.CurrentWorkbook(){[Name="Table21"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Question", type text}, {"Answer", type text}}),
        
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Question]), "Question", "Answer")
    in
        #"Pivoted Column"