Forum Discussion
Dicken
Post Prodigy
9 months agoAdjusting positions in a list
Hi, can anyone come up with a way to adjust posiotns of change in a list, so they can be used with List.accumulate to insert rows, i have use List.TransformMany, ; so to insert at each chaan...
lbendlin
Super User
9 months agoIf you don't like that approach you can go for something simpler
let
Source = {"a", "a", "a", "b", "b", "b", "b", "c", "c", "d", "d", "d", "e","a","a","b"},
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 0, 1, Int64.Type),
#"Grouped Rows" = Table.Group(#"Added Index", {"Column1"}, {{"Rows", each _, type table [Column1=text, Index=number]}, {"MinIndex", each List.Min([Index]), type number}},GroupKind.Local),
#"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"Index"}, {"Index"})
in
#"Expanded Rows"Dicken
Post Prodigy
9 months agothanks but i was really interested in a list generate approach.
- lbendlin9 months ago
Super User
let Source = {"a", "a", "a", "b", "b", "b", "b", "c", "c", "d", "d", "d", "e","a","a","b"}, Changes = List.Generate(() => 0, each _ < List.Count(Source), each _ +1 , each if _ = 0 then 0 else if Source{_}=Source{_-1} then 0 else 1) in Changes