Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
I want to accumulte the but as ans average, so : { 1, 1, 1 ,1} = 1 / 1 , 2 /2 , 3/3 , 4/ 4
so here the average is calculated in select;
let
alist =
let
alist = List.Numbers(1, 12, 1)
in
alist,
result = List.Generate(
() => [x = 0, y = alist{0}, z = y / (x + 1)],
each [x] < List.Count(alist),
each [x = [x] + 1, y = alist{x}, z = [z] + y],
each [z] / ([x] + 1)
)
in
result
but can i get the average in the function, i have tried various such as ;
= List.Generate
()=> [ x = 1 , y = alist {0} , z = y / x ] ,
each [x] < List.Count( alist ),
each [ x = [x] + 1, y = alist {x} , z = List.Sum( { [z], y} ) / x ],
each [z] )
i have played around with various x = 0 , x = 1 etc. but cannot get one to work?
Solved! Go to Solution.
I want the cuumulative average, the example i gave shows a correct result.
Hi
List.Transform(
{1..List.Count(alist)},
each List.Average(List.FirstN(alist, _))
)
List.Generate(
()=>[i=1, x=alist{0}],
each [i]<=List.Count(alist),
each [i=[i]+1, x= ([x]*[i]+alist{[i]}) / ([i]+1) ],
each [x]
)
Stéphane
Not sure what you want for a result.
What result would you like to see for your List.Numbers(1,12,1) list?
Your code gives the average where for each row n, the average of values alist{0..n}
Perhaps if you gave an example other than {1,1,1,1}??
posssibel method adapted from post prodigy;
let
alist = {1..12},
Custom1 = List.Generate( ()=> 1,
each _ < List.Count( alist ) ,
each _ + 1, each List.Average( List.Range( alist, 0,_ )) )
in Custom1
o as is said, but done within the fuunction, not select part of generate so;
Still not sure exactly what you want.
If you want a standalone function that will do the computation, then try:
(alist as list)=>
List.Generate(
()=>[a=alist{0}, idx=0],
each [idx] < List.Count(alist),
each [idx=[idx]+1, a = List.Sum(List.Range(alist,0, idx+1))/(idx+1)],
each [a])
You could use like:
let
alist = List.Numbers(1,12,1),
avg = fnRunningAvg(alist),
tbl = Table.FromColumns({alist, avg}, type table[Numbers=Int64.Type, Running Avg = number])
in
tbl
Good idea, but it can be somplfied so no need for a record and use avverage instead of sum,
i have posted as a solution, I'm nto sure how effecient range is .
I want the cuumulative average, the example i gave shows a correct result.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.