Calculations Syntax
This is a guide to the syntax details of calculations (used for evaluating mathematical formula such as summing the values of branches in a mind-map). For a quick-start guide, see Use Calculations in Coggle.
A calculation block is either:
- part of a line of text, starting with
=(, and ending with a matching). - a whole line starting with
=, followed by a number, function, or variable. Note that lines starting with=followed by lowercase letter (or otherwise not a valid number or variable) are ignored and not highlighted as errors.
A single item may have any number of calculation blocks across one or multiple lines of text.
Numbers within a calculation may be:
- Integers:
123 - Decimal numbers:
123.456 - Hexadecimal integers:
0x123abc - Scientific notation numbers:
1.2e9,1.23E-12,123E+4etc.
Calculations are not aware of percentages or currencies (calculations deal only with dimensionless numbers, not numbers with units). To use a currency, percentage, or unit symbol, place the symbol outside of the calculation. For example: $=(12.99), =(95)%, or =(123)lbs which would be displayed as $12.99, 95%, and 123lbs.
Functions and Variables:
All functions and variables in calculations are always in UPPERCASE, and will only use the characters A-Z and..
When a calculation references others using the variables like CHILDREN, LEAVES, or PARENTS, it only references other calculation blocks. So to include a number in a calculation, be sure to place it within a block such as =(123).
The values that functions operate on are contained within parentheses immediately following the function name, separated with ,. Variables that represent multiple values are "flattened" into the argument list. That is, a function like SUM(1, 2, LEAVES), where the LEAVES has blocks =(3) and =(4), is equivalent to SUM(1, 2, 3, 4).
Functions can be nested, with the result of the inner function passed to the outer one. For example: SUM(1, 2, MAX(3, 4)) is equivalent to SUM(1, 2, 3).
A variable can be used multiple times within a block. For example, to calculate the average value (without using the AVERAGE
Errors in calculations
Errors will highlight the part of the expression that has caused the problem, such as the misspelled function or variable name. Hovering over the highlighted area will provide details.