Forum Discussion
dof
4 years agoNew Member
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...
- 4 years ago
Hi dof
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
PhilipTreacy
4 years agoSuper User
Hi dof
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
dof
4 years agoNew Member
works perfectly....thanks Phil!