gabriel119435
gabriel119435

Reputation: 6802

how to sum values only if adjacent cell is filled?

i have this table:

A B C
1 value date creditOrDebit
2 10 C
3 8 03/30/23 D
4 3 11/11/23 C
5 sumCreditSubtractDebitOnlyWithDate
6 -5

since rows 3 and 4 have dates on B3 and B4, i consider A3 and A4 only, ignoring A2 because B2 is null. since C3 is a debit and C4 is a credit, i evaluate -8 + 3 = -5.

which formula would give me this result on A6?

Upvotes: 1

Views: 94

Answers (1)

rockinfreakshow
rockinfreakshow

Reputation: 29982

You may try:

=sum(map(A2:A,B2:B,C2:C,lambda(a,b,c,if(a="",,if(isdate(b),ifs(c="C",1,c="D",-1,1,)*a,)))))

enter image description here

Upvotes: 1

Related Questions