#powerquery #power_query
Starting Table:
= #table({"Name"}, {{"a"},{"a"},{"a"},{"b"},{"b"},{"b"},{"c"}})
Full Advanced Editor Code (Will need to add Greater and Less Than Symbols instead of ˂˃):
let
Source = #table({"Name"}, {{"a"},{"a"},{"a"},{"b"},{"b"},{"b"},{"c"}}),
List = Source[Name],
List2 = List.Generate (
()=˃ [Counter = 1, Occ = 1],
each _[Counter] ˂= List.Count(List),
each [Counter = _[Counter] + 1, Occ = if List{_[Counter]} = List{_[Counter]-1} then _[Occ] + 1 else 1],
each _[Occ]
),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Occurance", each List2{[Index]}),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
#"Removed Columns"
Ещё видео!