Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I set text based on two variables?

I would like to set a variable to display text in Writer 4 on the basis of two other variables, e.g.:

  1. If A is true and B is true, set C to display "one".
  2. If A is true and B is false, set C to display "two".
  3. If A is false and B is true, set C to display "three".
  4. If A is false and B is false, set C to display "four".

I want to set C as a variable as I will be displaying the resulting text multiple times throughout the document.

I have not been able to figure out a way to accomplish this. I tried using hidden sections, but hidden sections only don't print; they still affect the value of variables even if hidden.

I also tried using Insert > Field > Other > Insert Formula, but couldn't come up with a formula that Writer recognized as valid. Specifically, I tried using a Calc compound IF:

IF(A EQ "1",IF(B EQ "1","one","two"),IF(B EQ "1","three","four"))

but got an error message.

On the other hand, there doesn't seem to be a way to set a variable based on a compound condition, at least not so I can get four different results.

Is there a reasonable way to accomplish this without manually having to change the value of C every time I change the value of A or B, which also control text throughout the document?