==SCAN(initial_value,array,lambda)
=SCAN(0,B5:B16,LAMBDA(a,v,a+v))
The SCAN function can be used to return the running sum of values in a range. For example, the formula returns the running sum of values in the range B5:B16.
=SCAN(0,{1,2,3},LAMBDA(a,v,a+v))
The SCAN function can be used to return an array of values. For example, the formula returns {1,3,6}.
=SCAN(1,{1,2,3},LAMBDA(a,v,a*v))
The SCAN function can also be used to calculate more complex values in an array. For example, the formula returns {1,2,6}, which is the product of all the values in the array.
=SCAN(0,{1,2,3},LAMBDA(a,v,IF(v>1,a+v,a)))
The SCAN function can also be used to calculate values based on a condition. For example, the formula returns {0,3,5}, which is the sum of all values greater than 1 in the array.
The SCAN function is a powerful tool that can quickly apply a custom LAMBDA function to each element in an array, resulting in an array of the intermediate values created during the process.