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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jraj2380
New Member

Pivoting Issue.

@Getting count while doing Pivot of below table, need to Sum of Values against each Executive and Attributes as column headers. Thank you.

ExecutiveAttributeValue
JAIOD234242
JAIOS343243
GIRIOD324232
GIRIOS543533
3 REPLIES 3
Jraj2380
New Member

Thank you Jennaratten..👍

You're welcome!  If this worked for you please click Accept as Solution.

jennratten
Super User
Super User

Hello - I have provided two options below. Please let me know if you have any questions.

  1. The attribute is the column headers with the executive as the row label and the sum as the value. 
  2. The column headers as executive + attribute with no row label.  

 

Option 1 steps:

jennratten_0-1692355393152.png

Option 1 Result

jennratten_1-1692355434442.png

Option 1 Script

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

 

Option 2 Script for exec + attribute as headers.  It is just like option 1 but you have to add a combined column first and then pivot on that.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nL0VNJR8ncBEkbGJkYmRkqxOnDRYCBhbGJsZGIMFnX3DIIrBgoaGRuhCINUm5oYmxoDVccCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Executive = _t, Attribute = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Temp", each [Executive] & "_" & [Attribute]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Executive", "Attribute"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Temp]), "Temp", "Value", List.Sum)
in
    #"Pivoted Column"

 

Option 2 result

jennratten_2-1692355728491.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.