Search code examples
google-sheetsgoogle-sheets-formulagoogle-sheets-query

Making a formula that adds to a value based off of the data in other cells


I am trying to make a formula that does the following (in the order below) in Column AJ:

If Column AA is blank, then add the dollar amount in Column Z to AJ
If Column V = "Us" AND Column AA = "Them", then add the dollar amount in Column Z to AJ 
If Column AG is blank, then add the dollar amount in Column AF to AJ
If Column V = "Us" AND Column AG = "Them", then add the dollar amount in Column AF to AJ 

So each step would add the new dollar amount (if any) to the existing amount in Column AJ.

I know how to do each of these lines as separate formulas, but I'm struggling how to combine them so that the formula will check the right columns and then continue to add up the sum.

Any help or guidance would be amazing!!!


Solution

  • =ARRAYFORMULA(
     IF((AA:AA="")+((V:V="Us")*(AA:AA="Them")), Z:Z,
     IF((AG:AG="")+((V:V="Us")*(AG:AG="Them")), AF:AF,)))
    

    0


    =ARRAYFORMULA(IF(LEN(V:V&Z:Z&AA:AA&AF:AF&AG:AG),
     IF((AA:AA="")+((V:V="Us")*(AA:AA="Them")), Z:Z)+
     IF((AG:AG="")+((V:V="Us")*(AG:AG="Them")), AF:AF, ), ))
    

    0