Help contructing a conditional add formula

I have a table in a writer doc that I wish to create a sum of a column but only if an adjacent cell on each line contains a specific character. And example would be to add the value of this row’s cell to the total IF the cell to the right contains the value of ‘1’.

I have:
=IF (<C3>=“1”,<C99>=+<B3>,)
Formula is not showing as I wrote it. It reads if cell C3 = 1 then to cell C99 add the cell B3
Formula formatting fixed by ajlittoz

Obviously I’m NOT a calc expert but in the above formula if the content of cell C3 is equal to a character ‘1’ then add the value of cell B3 to the value of cell C99.
The only message I receive is “** expression is faulty **” Uh huh!
But what IS the correct expression. Thanks for any/all who can provide some guidance?

For such a complex requirement, don’t do your calculations in Writer. Writer is a text processing application, not a spreadsheet. Tables in Writer primarily contain formatted text. Some simplistic arithmetics is offered as a courtesy goodie but don’t request too much.

The correct approach is to design your “table” in Calc and to import it as an OLE object.

In Calc, formulas are expressions to modify contents of the cell onto which the formula is attached. If you want to change C99, formula must be on C99. Considering your specification, I’m afraid you need matrix formulas. This mode is only available in Calc. And this is advanced usage.

I suggest you take another approach. In a spreadsheet, you can have as many columns as you want to make intermediate computations. You then hide these columns so that they don’t display when you print or import.

Your column B is where you enter your values. Column C contains the flag to add or not the cell in column B. Create a D column where you preprocess =IF(Cx=1;Bx;0), i.e. you copy the cell from column B or force a zero depending on the cell in column C.
At bottom of column C (C99), you =SUM(D1:D98) to retrieve the sum of the non-masked cells.

This approach is simpler, more reliable, less error-prone and easy to implement for a newbie (and used everyday by advanced users).

Edit: There was a typo in the formula which should reference the intermediate D column, not C.

1 Like

Thank you for your insight. I’m a system admin, not a calc guru so I’ll do what you say.
Thanks again.