Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Fabric community is now in read-only for platform upgrade. Learn more

Reply
NumeroENAP
Helper III
Helper III

Get forms data into structured lines

Hi,


This is an exemple of what I have :

 

QuestionsAnswers
Id1
Question 1A
Question 2A
Question 3A
Id2
Question 1B
Question 2B
Question 3B
Id3
Question 1C
Question 2C
Question 3C


And this is what I want to get :

 

IDQuestion1Question2Question3
1AAA
2BBB
3CCC


Thank you

1 ACCEPTED SOLUTION
artemus
Microsoft Employee
Microsoft Employee

Something like this (substitute YourTable with your table name):

 

let
    Source = YourTable,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Questions", type text}, {"Answers", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Questions"}, {{"Rows", each [Answers], type {text}}}),
    #"Transposed Table" = Table.Transpose(#"Grouped Rows"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Id", type any}, {"Question 1", type any}, {"Question 2", type any}, {"Question 3", type any}}),
    Custom1 = Table.FromRows(List.Zip(Record.FieldValues(#"Changed Type1"{0})), Table.ColumnNames(#"Changed Type1"))
in
    Custom1

 

View solution in original post

4 REPLIES 4
artemus
Microsoft Employee
Microsoft Employee

Something like this (substitute YourTable with your table name):

 

let
    Source = YourTable,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Questions", type text}, {"Answers", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Questions"}, {{"Rows", each [Answers], type {text}}}),
    #"Transposed Table" = Table.Transpose(#"Grouped Rows"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Id", type any}, {"Question 1", type any}, {"Question 2", type any}, {"Question 3", type any}}),
    Custom1 = Table.FromRows(List.Zip(Record.FieldValues(#"Changed Type1"{0})), Table.ColumnNames(#"Changed Type1"))
in
    Custom1

 

Anonymous
Not applicable

Hi @artemus.,

 

very interesting solution, I did not even think into this direction.

I think you can slightly modify it to something like this to reduce compute-greedy transformations.

 

let 
    Source=...    
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Questions", type text}, {"Answers", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Questions"}, {{"Rows", each [Answers], type {text}}}),
    Output = Table.FromColumns(#"Grouped Rows"[Rows], #"Grouped Rows"[Questions])
in
    Output

 

Kind regards,

JB

 

You're a genius angel. Thanks a lot!

Anonymous
Not applicable

Presuming that you are power querying in excel

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Questions", type text}, {"Answers", type any}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "ID", each if [Questions] = "Id" then [Answers] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"ID"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Questions] <> "Id")),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Questions]), "Questions", "Answers", List.Min)
in
    #"Pivoted Column"

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.