Forum Discussion
Dicken
Post Prodigy
4 months agoList.Generate, make behave like Accumulate or XL REDUCE
Hi, my staring point was this, i wanted to accumute fieds to a record; so i used; let
f = {List.Sum, List.Max, List.Average},
head = {"sum", "max", "avg"},
pos = {0, 1, 2},
...
- 4 months ago
and try this
let f = {List.Sum,List.Max, List.Average}, head = { "sum", "max", "avg"}, val = {2,3,1,5,2,1}, to= List.Generate(()=> [ i = 0, j = Record.AddField( [],head {i}, f{i}(val) ) ], (x)=> x[i] <= List.Count( head)-1, (x)=> [i = x[i] + 1, j = Record.AddField( [],head {i},f{i}(val)) ], (x)=>x[j]) in Record.Combine( to)
Ahmedx
Super User
4 months agoand try this
let
f = {List.Sum,List.Max, List.Average},
head = { "sum", "max", "avg"},
val = {2,3,1,5,2,1},
to=
List.Generate(()=> [ i = 0, j = Record.AddField( [],head {i}, f{i}(val) ) ],
(x)=> x[i] <= List.Count( head)-1,
(x)=> [i = x[i] + 1, j = Record.AddField( [],head {i},f{i}(val))
],
(x)=>x[j])
in
Record.Combine( to)
- Dicken4 months ago
Post Prodigy
Thanks, will work through properly, i like anythiing that invvolvves records 😊
- Ahmedx4 months ago
Super User
let f = {List.Sum, List.Max, List.Average}, head = {"sum", "max", "avg"}, val = {2, 3, 1, 5, 2, 1}, to = List.Generate( () => 0, (x) => x <= List.Count(f) - 1, (x) => x + 1, (x) => Record.FromList({f{x}(val)}, {head{x}}) ) in Record.Combine(to) ============================ let f = {List.Sum, List.Max, List.Average}, head = {"sum", "max", "avg"}, val = {2, 3, 1, 5, 2, 1}, to = List.Generate( () => 0, (x) => x <= List.Count(f)-1, (x) => x + 1, (x) => Record.AddField([],head {x}, f{x}(val) )) in Record.Combine(to)