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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
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