Buy & sell formula

Sarah7828

New Member
Joined
Oct 25, 2024
Messages
6
Office Version
  1. 2021
Hi

I have the following data:

ColumnA. Column B
Buy 3
Sell -2
Buy 4
Sell -6

I have created a Sumif function as follows:


Sumif(a:a, “Buy”, b:b) - sumif(a:a, “Sell”, b:b)


However , it doesn’t provide me with the correct net amount as the sells are negative values

Is there away I can you the ABS function in the sell formula to get me the result? Or is there a better formula altogether?

Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
There's several ways. Because your sell amounts are negative, then you should add the SUMIFS
Excel Formula:
=SUMIF(A1:A4,"Buy",B1:B4)+SUMIF(A1:A4,"Sell",B1:B4)
or you could take the absolute value of the sells and subtract
Excel Formula:
=SUMIF(A1:A4,"Buy",B1:B4)-ABS(SUMIF(A1:A4,"Sell",B1:B4))
or, again because the sell amounts are negative, you could just sum column B
Excel Formula:
=SUM(B1:B4)

All of these give the same answer (-1)
 
Upvote 0
Solution
There's several ways. Because your sell amounts are negative, then you should add the SUMIFS
Excel Formula:
=SUMIF(A1:A4,"Buy",B1:B4)+SUMIF(A1:A4,"Sell",B1:B4)
or you could take the absolute value of the sells and subtract
Excel Formula:
=SUMIF(A1:A4,"Buy",B1:B4)-ABS(SUMIF(A1:A4,"Sell",B1:B4))
or, again because the sell amounts are negative, you could just sum column B
Excel Formula:
=SUM(B1:B4)

All of these give the same answer (-1)
Thank you so much . . I will use the 2nd .- take you for confirming
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top