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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power Query - Pivot values to columns

Hi,

 

I have an ID with some other fields with 3 corresponding questions and a rate :

 

 ID  ....   QUESTION   RATE

A1  ....   Q1                 2

A1  ....   Q2                 3

A1  ....    Q3                 1

 

I would like to have this result :

ID  ....   Q1   Q2    Q3  

A1 ....   2      3       1

 

I need to do it in Power Query in order to be able to reproduce this transformation and use the same model for different CSV files but I am not able to do it because I can't use RATE in "Values Column", why ? How can i do it, please ?

 

Thank you !

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Anonymous Please try to pivot the Question column and select "Don't Summarize". Below is the code that you can paste in the Advanced Editor in Power Query Editor.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lEKBBFGSrE6ML4RkDBG4hsDCUOl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Question = _t, Rate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Question", type text}, {"Rate", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Question]), "Question", "Rate")
in
    #"Pivoted Column"

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

2 REPLIES 2
PattemManohar
Community Champion
Community Champion

@Anonymous Please try to pivot the Question column and select "Don't Summarize". Below is the code that you can paste in the Advanced Editor in Power Query Editor.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lEKBBFGSrE6ML4RkDBG4hsDCUOl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Question = _t, Rate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Question", type text}, {"Rate", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Question]), "Question", "Rate")
in
    #"Pivoted Column"

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

It's working, thanks a lot !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.