Forum Discussion
VictorVidaurre
Mar 21, 2023Copper Contributor
Lambda #VALUE! Error
I have a simple formula to calculate the running total in a row of numbers that works as expected by itself, but generates a #VALUE! error when wrapped in a Lambda function. At this point I don't car...
JosWoolley
Mar 22, 2023Iron Contributor
Yes, it's an unfortunate feature of LAMBDA/MAKEARRAY constructions that MAKEARRAY forces a range passed as a parameter to LAMBDA to be first internalized to its equivalent array.
Usually this is not an issue, as the vast majority of functions process ranges and arrays equivalently, though with the INDEX construction you are employing here, only a range will suffice.
You can see that the issue lies with the combination of LAMBDA with MAKEARRAY, and not just with LAMBDA per se, since, for example:
=LAMBDA(vector, SUM(INDEX(vector, 1):INDEX(vector, 3)))(A1:F1)
is perfectly valid.
For your case you could switch to SCAN:
=LAMBDA(x, SCAN(0, x, LAMBDA(a, b, a + b)))(A1:F1)