Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have survey data that comes in a pretty poor format and need assistance reformatting. When a question is asked multiple times in the survey, each response is placed in a new column. An example question is, "What Position are you At?" Each reponse from the person performing the survey creates a columns. I need a way to put all the columns of data into 1 long column. I will provide an example below. Is this possible?
Person | Position | Position2 | Position3 |
A | 1 | 2 | 3 |
B | 1 | 2 | 3 |
C | 1 | 2 | 3 |
Needs turned into:
Position |
1 |
2 |
3 |
1 |
2 |
3 |
1 |
2 |
3 |
Solved! Go to Solution.
Yes it is possible.
Here is the M Query code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYiMgNlaK1YlWcsIQcUYViQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Person = _t, Position = _t, Position2 = _t, Position3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Person", type text}, {"Position", Int64.Type}, {"Position2", Int64.Type}, {"Position3", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Person"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute", "Person"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Position"}})
in
#"Renamed Columns"
Your source:
Output:
Yes it is possible.
Here is the M Query code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYiMgNlaK1YlWcsIQcUYViQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Person = _t, Position = _t, Position2 = _t, Position3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Person", type text}, {"Position", Int64.Type}, {"Position2", Int64.Type}, {"Position3", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Person"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute", "Person"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Position"}})
in
#"Renamed Columns"
Your source:
Output:
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
78 | |
65 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |