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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
annag815
Frequent Visitor

Turn rows into columns

Hi everyone, 

 

Currently my data looks like this: 

annag815_0-1614977224970.png

 


I need it to look like this: 

annag815_1-1614977249416.png

 

How would I accomplish this? 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @annag815 

 

Download PBIX file with solution

 

In the Power Query Editor (click on Transform data in the PBI Ribbon) , select the Question and Answer columns then select Pivot Column from the Transform tab

piv1.png

 

In the Pivot Column dialog box choose Answer as the Value column and in Advanced options set the aggregate type to Don't Aggregate

piv2.png

 

Which gives this result

piv3.png

 

Here's the code which is in the PBIX file I linked to above

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrUg5IKjnnF5alFSrE6MAkjCIkpYQwhkSWMcBllhMsoI6xGxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Inspection = _t, Question = _t, Answer = _t]),
    #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[Question]), "Question", "Answer")
in
    #"Pivoted Column"

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
performl
New Member

Hi there, 

I have a similar problem except my dataset is incomplete. 

As you can see in the picture below, each row in the third column (Registration Group) should be its own column against each row in the first column (Registered Provider Name) - except where a registered provider (colmn 1) has multiple registration groups (colmn 3), colmn 1 is empty / vacant. 

So I think to be able to use the pivot function I need to somehow populate each row in colmn 1 with the correct registered provider name, but is there an easy way to do this? 

Many thanks in advance.

 

Power BI questions.PNG

PhilipTreacy
Super User
Super User

Hi @annag815 

 

Download PBIX file with solution

 

In the Power Query Editor (click on Transform data in the PBI Ribbon) , select the Question and Answer columns then select Pivot Column from the Transform tab

piv1.png

 

In the Pivot Column dialog box choose Answer as the Value column and in Advanced options set the aggregate type to Don't Aggregate

piv2.png

 

Which gives this result

piv3.png

 

Here's the code which is in the PBIX file I linked to above

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrUg5IKjnnF5alFSrE6MAkjCIkpYQwhkSWMcBllhMsoI6xGxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Inspection = _t, Question = _t, Answer = _t]),
    #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[Question]), "Question", "Answer")
in
    #"Pivoted Column"

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thank you! 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.