devR
devR

Reputation: 73

Coverting Formula with an If Statement

I am struggling with the logic behind how I would make the second filter an if statement.

Here's the formula.

=sum(filter($C$2:$C$6,$B$2:$B$6=A10,$A$2:$A$6="BUY"))-sum(filter($C$2:$C$6,$B$2:$B$6=A10,$A$2:$A$6="SELL"))

The problem is not all the codes will immediately have a sell therefore there is no sell number to subtract so an error is caused.

enter image description here

Thanks!

Upvotes: 0

Views: 36

Answers (1)

Harun24hr
Harun24hr

Reputation: 36750

You can try SUMIFS()

=SUMIFS($C$2:$C$6,$B$2:$B$6,A10,$A$2:$A$6,"Buy")-SUMIFS($C$2:$C$6,$B$2:$B$6,A10,$A$2:$A$6,"Sell")

enter image description here

Upvotes: 1

Related Questions