Forum Discussion

k1s1's avatar
k1s1
Helper I
5 years ago
Solved

Pivot columns vs group

Hello   I'm struggling with pivoting and grouping amd woudl greatly appreciate some help   I have a few hundred rows of data like this:   5 Ideas a "Score before" from 1-7 and an Uplift also be...
  • Jimmy801's avatar
    5 years ago

    Hello k1s1 

     

    not able to follow you. Could you please a few lines of your dataset and what the expected result is of that. What I understood is that this "9" is a count of rows where idea5 with rating 4 and uplift 9. I'm wrong? If not try this... add a count-column with each 1. Then pivot the Uplift-column and summing the count-column. Here the code

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykxJTTRR0lECYXOlWB1CIkYoIsZkiRgBsSGGCKYaY6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Idea = _t, #"Score before" = _t, Uplift = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Idea", type text}, {"Score before", Int64.Type}, {"Uplift", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Count", each 1, type number),
        #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Added Custom", {{"Uplift", type text}}, "de-DE"), List.Sort(List.Distinct(Table.TransformColumnTypes(#"Added Custom", {{"Uplift", type text}}, "de-DE")[Uplift]), Order.Ascending), "Uplift", "Count", List.Sum)
    in
        #"Pivoted Column"

    transforms this

     

    into this


    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy