Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Spreadsheet, operations with above row cell in same column with arrayformula

I have arrayformula in the first row of a column so my values and calculations can start in Row 2 and for all the column length.

I have this situation:

https://docs.google.com/spreadsheets/d/11oDra7Vja4-5C0Uix7JTgLLSMG3gPj-6fkajXlWqqQk/edit?usp=sharing

Test

I need a simply arithmetic operation:

Subtract above value of the same column for every row.

I'm using:

=arrayformula(IF(row(A:A)=1; "What I have now"; IF(ISBLANK(A:A); ""; A1:A-A2:A)))

but as you see is wrong.

How to do that?

UPDATED QUESTION:

And then in the second sheet I need a SUM operation with some blank cells in column:

Test2

How to do that?

https://docs.google.com/spreadsheets/d/11oDra7Vja4-5C0Uix7JTgLLSMG3gPj-6fkajXlWqqQk/edit#gid=931743679


1 Answers

If you want to have the array formula ion the header this is a bit weird as you need to allow the formula to technically access row 0, we can do this by constructing ranges.

=ArrayFormula(IF(
  --(ROW(A1:A) > 2) + -ISBLANK(A1:A) = 1; 
  {0; A1:A} - {0; A2:A; 0}; 
  ""))

--(ROW(A1:A) > 2) + -ISBLANK(A1:A) = 1 Checks if the row is populated and not one of the first two rows in a way that works nicely with array formulas

{0; A1:A} - {0; A2:A; 0} does the following:

0   Data   156    123   110    95    42
-   -     -      -     -     -     -
0   156    123    110    95    42     0
=   =     =      =     =     =     =  
0    33     13     15    53    42    42
N     N      Y      Y     Y     Y     N <- Is shown  
^     ^                               ^
|     |                               Because Row is blank
|     |
Because row not > 2, thus it is never evalauated even though the second would cause an error
like image 98
Robin Gertenbach Avatar answered Dec 09 '25 21:12

Robin Gertenbach