How to Write a Formula for an Attribute

Briefly

Click on an attribute name in a case table and choose Edit Formula from the Edit menu to open the formula editor. Enter the formula for the attribute there.

To calculate the values of an attribute from the values of other attributes, you write a formula telling Fathom how to do the calculation.

For example, if your student data has height expressed as two attributes, feet and inches, you might write a formula for heightInInches which would be 12 * feet + inches. If you had time and distance, you might make speed.

You write the formula in the formula editor. A formula is not a complete equation - it is an expression for computing the value of an attribute. We'll use the example from above, where we'll define speed to be distance / time.

1. Make a new attribute to hold your calculated values (see How to make New Attributes).

2. In a case table for the collection, click on the attribute name and choose Edit Formula from the Edit menu. The formula editor appears.

Alternatively, bring up the contextual menu for the attribute (as shown below) and choose Edit Formula. Or double-click in the formula box for the attribute. These two methods work equally well in the collection inspector.

3. Enter the formula. Type just the right-hand side; no equals-signs. Use the asterisk ("*") for multiplication and the slash ("/") for division. For our example, type "distance / time" (but no quotes). There's a lot you can do with this editor. For more, see How to use the Formula Editor.

4. Click OK to close the formula editor. You should see the new values in the table column. (If you press or click Apply, you can see the results in the table, but the formula editor stays open.)

Some attributes may require formulas with conditional expressions (e.g., if-statements).

Note: You can use the same contextual menu that gives you Edit Formula to use Cut, Copy, Paste, and Clear with formulas. These commands are perfect for removing formulas from attributes (while preserving their values) and for giving the same formula to many attributes.

Other uses of formulas:

Plotting functions

Writing formulas for statistics

Writing filters