Spreadsheet if else sum

107 views Asked by At

I would appreciate some help writing a statement in a spreadsheet (Libreoffice).

IF E4 contains "bought" then do the sum of I4-F4 ELSE / ELSEIF E4 contains "sold" do the sum of F4-I4.

I have it partially working: if E4 contains "bought" the correct sum is displayed, but if E4 contains "sold" then #VALUE! is displayed.

2

There are 2 answers

0
chris On BEST ANSWER

something like:

if(exact(e4;"bought");i4-f4;if(exact(e4;"sold");f4-i4))

works for you???

0
Chris Hick On

Does this formula work as you want:

=IF(IFERROR(SEARCH("bought",E4),0)>0,I4-F4,IF(IFERROR(SEARCH("sold",E4),0)>0,F4-I4,""))