Search code examples
arraysgoogle-sheetslambdagoogle-sheets-formulaarray-formulas

formula to add three columns automatically when new row is added


I am trying to automatically add a formula in Google sheets when row is added. The formula is an output of adding (sum) three columns.

Here is my formula:

=ARRAYFORMULA(IF(ROW(F:F)=1, "Count", IF(ISBLANK(F:F), "", SUM(F2:H2))))

The above formula populates the sum of SUM(F2:H2) in all the rows

If I use this formula:

=ARRAYFORMULA(IF(ROW(F:F)=1, "Count", IF(ISBLANK(F:F), "", SUM(F:H))))

Then the output is the total sum of column F, G, H


Solution

  • You can use BYROW to have the sums of each row. Put this in Row 1 of your column

    ={"Count";BYROW(F2:H,LAMBDA(each,IF(COUNTA(each)=0,"",SUM(each))))}