Forum Discussion

dof's avatar
dof
New Member
4 years ago
Solved

Trouble referencing a field

So I have a table such as the one below which I call tblCodes I want to Group By the distinct Codes, and in my aggregation get the position number(s) of each Code (in a list that I made.) This is m...
  • PhilipTreacy's avatar
    4 years ago

    Hi dof 

     

    Download sample PBIX file

     

    Try this instead

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1QGSxhDKFEIhi1nAObEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Code = _t]),
        mytable = Table.TransformColumnTypes(Source,{{"Code", Int64.Type}}),
        #"Grouped Rows" = Table.Group(mytable, {"Code"}, {{"Grouped Code", each _, type table [Code=nullable number]}}),
        List_CODES = List.Buffer(mytable[Code]),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each List.PositionOf(List_CODES, [Code], Occurrence.All)),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Grouped Code"})
    in
        #"Removed Columns"

     

     

    Regards

     

    Phil