Functions and Variables Reference for Calculations
This is the currently supported list of functions and variables for Calculations in Coggle diagrams. If there's something missing that you'd find useful, let us know at hello@coggle.it – we're always to interested to hear about the ways you use Coggle and how we can make it better!
Variables
Variables must always be in uppercase letters. Most variables resolve to an array of multiple values, which means you need to use a function like SUM.
When a variable is used in an additive expression, like =(1 + CHILDREN), or used on its own =(LEAVES) all of its values are summed: the separate values are never displayed in a result.
CHILDREN |
The values of all of the immediate children of this item (items connected by a single branch pointing away from this item) |
LEAVES |
The values of all of the items that are descended from this item (with branches pointing from this item to them), only if they have no children of their own (i.e. not including intermediate items. This is the most useful variable for creating budget-like totals, as intermediate totals can be added without affecting the total. |
PARENT |
The value of the calculation in the parent of this item (connected with a branch pointing from the parent item to this one). If there is not exactly one calculation in this item's parents, this variable produces an error. |
PARENTS |
The values of all of the parents of this item (connected with a branch pointing from the parent item to this one). |
ROOTS |
The opposite of leaves - all the values in items with no parents (no branches pointing in to them) which this item is connected to by following branches. |
Functions
Functions must always be uppercase, and always use brackets around their arguments. Function arguments are separated by a comma.
An array variable may be used as a single argument, for example: =(MAX(6, LEAVES)) will return 6 if 6 is greater than any of the values in leaves, otherwise the maximum value in a leaf calculation.
Functions may be composed, for example =(MIN(COUNT(CHILDREN), 5)) will return the number calculations in child items, limited to maximum of 5.
AVERAGE |
The average (mean) of the values. Produces an if there are no values. |
COUNT |
The number of values passed. |
MAX |
The maximum (or most positive) value. |
MIN |
The minimum (or most negative) value. |
STDEV.S |
The standard deviation, based on a sample of values. Produces an error if there are less than two values. |
SUM |
The sum of the values passed. |
SUMSQ |
The sum of the values, each squared. Useful for some statistical calculations. |
SQRT |
The square root of the value. Accepts exactly one value only. |