The documentation of the Google Sheets function arrayformula
says
Enables the display of values returned from an array formula into multiple rows and/or columns and the use of non-array functions with arrays.
This is working well in the following case which simply divides all the values in column A by five:
=arrayformula(A2:A / 5)
Now I want to lower-bound the result in every row by 0, i.e. in row n I want to compute max(An, 0)
. This is my non-working attempt:
=arrayformula(max(A2:A / 5, 0))
The max
itself would work perfectly without the use of arrayformula
, i.e. if I fill max(A2 / 5, 0)
down all rows I get exactly what I want. I want the max
function to operate on two single values, the single value found in An and the constant 0. The reason why the arrayformula
approach is not working is that the max
"steals" the range, aggregating the entire range A2:A
into a single number. Thus, arrayformula
operates on only this number and entirely ignores the range A2:A
, consequently producing the same value for all cells.
How do I make the arrayformula
interpret the range A2:A
, or rather, how do I prevent the max
function from doing so and have it operate on two single values instead?
(I can solve the issue with an if
function instead, but that does not seem particularly elegant and requires a lot of code repetition, in particular since my real problem uses more involved arithmetic and a combination of min
and max
.)