Forum Discussion

Clyde's avatar
Clyde
New Member
2 years ago
Solved

Help with consolidating multiple rows for same person

Hello, 👋  First time here, newbie at Power BI but a fast learner. I am trying to optimize a report directly in power BI. I was able to use VBA to create the report I need and then import it into P...
  • MFelix's avatar
    2 years ago

    Hi Clyde ,

     

    Select the Column element the do a transform and Pivot columns where the unit are used in values:

     

    Final resul will be what you need.

     

    Check complete code here:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjbQNzTQNzIwMlbSUfJLzE1VMAQyXBOTM1KLgQw9MyBhYmAAYpooxerg0hCQmJOTWgLXoWdKSINzYnEqTLU5VHEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Element = _t, Time = _t, Unit = _t, Usage = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Name", type text}, {"Element", type text}, {"Time", type number}, {"Unit", type number}, {"Usage", type number}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Element]), "Element", "Unit", List.Sum)
    in
        #"Pivoted Column"