Forum Discussion

lalithprasads's avatar
lalithprasads
Frequent Visitor
5 years ago
Solved

Pivot Table - Don't Aggregate populating errors

Hello, I am trying Pivot and I get errors instead of names in two rows. please let me know what am i doing wrong? thank you.       I want to acheive something like this -   USA...
  • Ashish_Mathur's avatar
    Ashish_Mathur
    5 years ago

    Hi,

    This M code works

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8stMzlbSUQoNdlSK1YlWckrMSQRyPfNSMhPBAt6JJalAAde89JzEvBSwkG9+aV4JmlhAaU5mcSaySQGpOSCNTkWJVZk5UKOyE1FFwjKLEksQ1sUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sales man" = _t, Country = _t]),
        Partition = Table.Group(Source, {"Country"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
        #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"Sales man", "Index"}, {"Sales man", "Index"}),
        #"Pivoted Column" = Table.Pivot(#"Expanded Partition", List.Distinct(#"Expanded Partition"[Country]), "Country", "Sales man"),
        #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
    in
        #"Removed Columns"

    Hope this helps.