Sunday, December 10, 2006

How do I express if-statements in a formula?

Pages 3.0 has if-statements built in, but in Pages 2.0 and earlier there are no conditional functions for the formulas.

If you still use Pages 2.0 you can simulate if-statements in some cases.

To illustrate the principle, you may want to show the biggest of two numbers. You can then type:

=(A1>A2)*A1+(A2>A1)*A2

(For this you could also use "=MAX(A1,A2)" directly, but that is not as fun.)

As another example, you may want to fill cells conditionally. Let us assume that F2 should be transferred to a cell, if the value of E2 = 1, but not if E2 = 2. You can solve this with:

=F2*(E2-2)*-1

Well... almost solve it anyhow. You will get a 0 in the field, if E2 = 2, and there is no way you can hide that 0.

No comments: