Home > Back-end >  Power BI Pivot Columns Issue
Power BI Pivot Columns Issue

Time:01-04

My data looked like:

enter image description here


After Pivoting in Power BI - Power Query, my data now looks like:

enter image description here


How can I get rid of those null values so that my looks likes this ? --->

enter image description here


P.S --> I have tried the "DON'T AGGREGATE" method while Pivoting

CodePudding user response:

You're doing something wrong as I get your desired result using "don't aggregate".

enter image description here

enter image description here

enter image description here

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

CodePudding user response:

Correct I tried the same and got the same results - enter image description here

You have to select "ques" column and pivot values must be "ans".

#"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"ques", type text}, {"ans", type text}}), #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[ques]), "ques", "ans")

enter image description here

  • Related