Search code examples
arraysgoogle-sheetsgoogle-sheets-formulaarray-formulassubtraction

How do we use MINUS with array


as function MINUS(value1, value2) it only has 2 arguments

Do we have function like MINUS(array) and minus each row of an array?

Or need to use app-script to create the custom function?

my full length formula is

=MINUS(FILTER(C5:C20,LEFT(A5:A20)=" "=FALSE))

Column C contains numbers

Column A contains texts

which will always be changing

enter image description here


Solution

  • In my rather simple-minded comment above I suggested the 'MINUS' function for a range A1:A10 would just be

    A1-sum(A2:A10)
    

    Another way of doing it would be

    2*A1-sum(a1:a10)
    

    Applying this second formula to your filtered data gives:

    =2*array_constrain(filter(D:D,left(B:B)<>" ",D:D<>""),1,1)-ARRAYFORMULA(sumif(left(B:B,1),"<> ",D:D))
    

    In other words, find the first row with data in it, multiply by two and subtract the sum of all the data.

    enter image description here