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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ksab23
Helper I
Helper I

Transform raw data with messed up structure

hello all, 

I presume there will be no solution for this but before I endeavor on a tedious manual task I have to ask. I have a survey dataset that is simply put terrible. Instead of having one survey with all answers in one row, questions being column headers and values being ratings (image below)

ksab23_0-1677851102561.png
I have these, questions are broken down into values and for each question and user, I have a row with a response, etc. which makes the data unusable in visuals (image below)

ksab23_1-1677851122279.png


Is there any way I can transform questions into columns and attach ratings as values per each user survey (like the first image, and table below)? Data will be updated on a certain cadence, so I really want to automate this if possible...

UserQuestion 1Question 2Question 3
XAgree/5Strongly Agree/4free text
YDisagree/1Neutral/3free text



Thanks a lot!

 

1 ACCEPTED SOLUTION
Peter_Beck
Resolver II
Resolver II

Hi -

 

It looks like you start with this:

 

ScreenHunter_104 Mar. 03 13.20.jpg

...and want to end up with this...

 

ScreenHunter_105 Mar. 03 13.22.jpg

... is that the case?

 

If so, you should be able to use "Table.Pivot" to do this, I have attached an example below:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi1OLVIwVNJRCi4tKkutBDMDS1OLSzLz88Acx/Si1FSlWB0CSo2AHJfM4kRU1UZ4DPbTdySs0AjsApCRsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [UserID = _t, Survey = _t, QuestionText = _t, QuestionResponse = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"UserID", type text}, {"Survey", type text}, {"QuestionText", type text}, {"QuestionResponse", type text}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[QuestionText]), "QuestionText", "QuestionResponse")
in
#"Pivoted Column"

 

This is done by selecting the "QuestionText" column, selecting "Pivot Column" under "Transform", and selecting "QuestionResponse" as the "Values" column. Be sure to select "Don't Aggregate" under the "Advanced" option, because you are not aggregating numbers. "QuestionText" becomse columns, with the appropriate value from "QuestionResponse" in each column.

ScreenHunter_106 Mar. 03 13.26.jpg

 

Hope this helps!

 

Peter

View solution in original post

1 REPLY 1
Peter_Beck
Resolver II
Resolver II

Hi -

 

It looks like you start with this:

 

ScreenHunter_104 Mar. 03 13.20.jpg

...and want to end up with this...

 

ScreenHunter_105 Mar. 03 13.22.jpg

... is that the case?

 

If so, you should be able to use "Table.Pivot" to do this, I have attached an example below:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi1OLVIwVNJRCi4tKkutBDMDS1OLSzLz88Acx/Si1FSlWB0CSo2AHJfM4kRU1UZ4DPbTdySs0AjsApCRsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [UserID = _t, Survey = _t, QuestionText = _t, QuestionResponse = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"UserID", type text}, {"Survey", type text}, {"QuestionText", type text}, {"QuestionResponse", type text}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[QuestionText]), "QuestionText", "QuestionResponse")
in
#"Pivoted Column"

 

This is done by selecting the "QuestionText" column, selecting "Pivot Column" under "Transform", and selecting "QuestionResponse" as the "Values" column. Be sure to select "Don't Aggregate" under the "Advanced" option, because you are not aggregating numbers. "QuestionText" becomse columns, with the appropriate value from "QuestionResponse" in each column.

ScreenHunter_106 Mar. 03 13.26.jpg

 

Hope this helps!

 

Peter

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors