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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors