Enter a Formula for an Attribute

Entering and Editing a Formula

Briefly, click on an attribute name in a case table and choose Edit Formula 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, write a formula telling CODAP 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 in which we define speed to be distance/time.

  1. Make a new attribute to hold your calculated values (click on the plus sign on the top right of the table to add a new attribute).
  2. In a case table for the collection, click the attribute name and choose Edit Formula. The formula editor appears. 
  3.  Enter the formula. Type just the right side; no equals signs. Use the asterisk (“*”) for multiplication and the slash (“/”) for division. Click on the Insert Value button and select an attribute by name to insert into the formula. For our example, to get speed, click on "Insert Value," select "distance," type in the slash ("/"), then click "Insert Value" and select "time." There’s a lot you can do with this editor. To find possible formulas you can use and insert into the formula editor, click on the Insert Function button. Click on the name of the formula to insert it into the editor. You can click on the i to the right of a formula name to learn more about how to use the formula. 
  4. Click Apply to close the formula editor. You should see the new values in the table column.

Using Operators

Arithmetic operators: Addition (+), subtraction (–), multiplication (*), division (/ or ÷), modulo (%) and exponentiation (^) all respect the usual rules of algebra. So 3 + 4 * 5 = 23, and 3^2 – 6 / 2 = 6. 

Comparison operators

  • = (equals): "a" = "b" is false
  • != (not equals): 4 != 5 is true. (Can also use ≠.)
  • < (less than), <= (less than or equals), > (greater than) and >= (greater than or equals): 7 + 2 <= 9 is true. (Can also use ≤ and ≥.)
  • & (logical and): 3+2=5 & 4+3=7 returns true. (Can also use "and" and "AND".)
  • | (logical or): "a"="b" | "a" = "a" is true. (Can also use "or" and "OR".)

Additional resources

List of all functions in CODAP (in alphabetical order) 

List of all functions in CODAP (by category)


Was this Article Useful? 

Add new comment

Comments are closed for the CODAP Help site. If you have a question or problem, please post on the CODAP Help Forum instead. Thank you.