Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Pivoting error in power query

Hi Experts, How can we achieve below pivoting in Power Query or close to this? Please help?     Getting below error due to duplicate records for User 1, but values are different fpr this u...
  • grandtotal's avatar
    3 years ago

    You can try List.Distinct function as aggregation (not available through the UI):

     

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0ABKOjiCWUqwOspgTkDBCEwOpMwGLGaHrjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Template = _t, Title = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Title]), "Title", "Value", List.Distinct),
    #"Expanded AA" = Table.ExpandListColumn(#"Pivoted Column", "AA"),
    #"Expanded AB" = Table.ExpandListColumn(#"Expanded AA", "AB")
    in
    #"Expanded AB"

    Not perfect but maybe you can use it.