Formula Reference: Operators & Functions
Write a formula in a text object or a table column to calculate and format parameter values at output time. This page covers formula syntax and every operator and function you can use.
- To learn how to create parameters and embed them in text, read Variable Basics first.
- To search by goal ("show the Japanese era", "sum the line items"), see Template Capabilities.
Where to enter formulas
- Select a text object and open Edit text.
- Switch to the Variables & formulas tab at the top.
- Type the formula in Formula input. The result appears under Evaluation result as you type.
- Open Show available functions & operators to see the main functions and operators with examples.
The same formula syntax is used for table columns, chart labels and values, and checkbox conditions. In a table column, the formula is evaluated row by row.
Values used in the examples
The examples on this page assume these parameter values.
| Parameter | Value |
|---|---|
@amount | 1234567 |
@price | 1200 |
@qty | 3 |
@name | 山田 太郎 |
@code | INV-2026-001 |
@invoiceDate | 2026-10-01 |
@paid | false |
@note | '' (empty text) |
Syntax
| What | How to write it | Example |
|---|---|---|
| Parameter | @parameterName | @price, @customerName |
| Table column | @tableName.columnName | @items.unitPrice (the value on the current row) |
| Text | '...' or "..." | ' san', "USD" |
| Number | digits and a decimal point | 100, 0.1 |
| Boolean | true / false | true |
| Function | name(arg, arg, ...) | round(@price, 0) |
| Parentheses | ( ... ) | (1 + 2) * 3 |
- Always prefix parameters with
@. Without@(for exampleprice), the parameter is not referenced. - Function names are case-sensitive.
ifworks;IFfails with "Unknown function: IF". - Numbers cannot use exponent notation (
1e3) or start with a decimal point (.5); write0.5. - Inside text, write a line break as
\n. Escape the enclosing quote as\'/\". - Spaces and line breaks between parts of a formula are ignored.
Operators
| Kind | Operator | Meaning | Example → Result |
|---|---|---|---|
| Arithmetic | + | Add | @price + 100 → 1300 |
| Arithmetic | - | Subtract (also a sign, as in -@price) | @price - 200 → 1000 |
| Arithmetic | * | Multiply | @price * @qty → 3600 |
| Arithmetic | / | Divide | 10 / 4 → 2.5 |
| Arithmetic | % | Remainder | 10 % 3 → 1 |
| Comparison | == / != | Equal / not equal | @code == 'INV-2026-001' → true |
| Comparison | > < >= <= | Greater / less than | @price > 1000 → true |
| Logical | and | Both true | @price > 1000 and @qty < 5 → true |
| Logical | or | Either true | @price > 5000 or @qty > 1 → true |
| Logical | not | Negation | not @paid → true |
+does not join text. It adds both sides as numbers ('1' + '2'→3). Useconcat()to join text.==/!=also compare types. The number1and the text'1'are not equal (1 == '1'→false).><>=<=compare as numbers ('10' > '9'→true).- Dividing by zero renders as blank (
10 / 0,10 % 0). - Arithmetic on values that are not numbers renders as
NaN('a' + 1→NaN). - Decimal arithmetic can show rounding errors (
0.1 + 0.2→0.30000000000000004). Useround()before displaying.
Order of evaluation
Listed from first to last. Operators on the same line are evaluated left to right.
- Parentheses
( ... )and functions - Sign
-,not */%+-- Comparisons
==!=><>=<= andor
and and or have the same precedenceUnlike most programming languages, and is not evaluated before or; they are evaluated left to right. For example, 1 or 0 and 0 means (1 or 0) and 0, which is false. Always add parentheses when you mix and and or.
@price > 1000 and (@qty == 0 or @qty > 10)
Functions
The "Listed" column shows whether the function appears under Show available functions & operators in the editor. Functions that are not listed still work when you type them into the formula input (the input's syntax coloring shows their names as unlisted).
Conditions and logic
| Function | Syntax | Description | Example → Result | Listed |
|---|---|---|---|---|
if | if(condition, valueIfTrue, valueIfFalse) | Choose a value by condition | if(@price > 1000, 'High', 'Low') → High | Yes |
and | and(value1, value2, ...) | true if all are true | and(1, true) → true | No |
or | or(value1, value2, ...) | true if any is true | or(0, '') → false | No |
not | not(value) | Negate | not(@paid) → true | No |
isEmpty | isEmpty(value) | true if there is no value, whatever its type | if(isEmpty(@note), 'None', @note) → None | Yes |
0, empty text, andfalsecount as false.- Always pass all three arguments to
if(). If you omit the false value, the formula fails when the condition is false. To show nothing, pass''. - These behave like the
and/or/notoperators. For joining conditions, the operator form (@a > 0 and @b > 0) is easier to read.
What isEmpty treats as "no value"
| Value | isEmpty result |
|---|---|
| A parameter with no value, or a parameter that does not exist | true |
| Empty text, or text that is only whitespace (half-width or full-width spaces, line breaks) | true |
0, false, '0', non-empty text, dates | false |
0andfalsecount as false in anifcondition, butisEmptytreats them as values. An amount of0givesfalse.- To check that a value exists, write
not(isEmpty(@note)). - A table column (
@items.note) is checked row by row inside the table. Outside the table it checks the column as a whole:falseif the table has at least one row (even when the values are empty), andtrueif the table has no rows. - A table itself (
@items) cannot be checked. It givestrueeven when the table has rows, so you cannot use it to check whether a table has no rows.
Text
| Function | Syntax | Description | Example → Result | Listed |
|---|---|---|---|---|
concat | concat(value1, value2, ...) | Join values | concat(@name, ' 様') → 山田 太郎 様 | Yes |
length | length(text) | Number of characters | length(@code) → 12 | Yes |
left | left(text, count) | Characters from the start | left(@code, 3) → INV | No |
right | right(text, count) | Characters from the end | right(@code, 3) → 001 | No |
mid | mid(text, start, count) | Characters from the middle | mid(@code, 4, 4) → 2026 | No |
trim | trim(text) | Remove leading and trailing spaces | trim(' ABC ') → ABC | No |
upper | upper(text) | Uppercase | upper('abc') → ABC | No |
lower | lower(text) | Lowercase | lower('ABC') → abc | No |
replace | replace(text, search, replacement) | Replace text | replace(@code, '-', '/') → INV/2026/001 | No |
replaceAll | replaceAll(text, search, replacement) | Same as replace | replaceAll(@code, '-', '') → INV2026001 | No |
concat()turns numbers and booleans into text as they are (concat('a', 1, true)→a1true).- The
startofmid()is zero-based (the first character is0). right(text, 0)returns the whole text.replace()replaces every occurrence. The search text is matched literally (not as a regular expression).
Numbers
| Function | Syntax | Description | Example → Result | Listed |
|---|---|---|---|---|
comma | comma(number) | Add thousands separators | comma(@amount) → 1,234,567 | Yes |
round | round(number, decimals) | Round half up | round(1234.567, 2) → 1234.57 | Yes |
floor | floor(number) | Round down to an integer | floor(1234.5) → 1234 | Yes |
ceil | ceil(number) | Round up to an integer | ceil(1234.1) → 1235 | Yes |
abs | abs(number) | Absolute value | abs(-10) → 10 | Yes |
max | max(number1, number2, ...) | Largest value | max(10, 20, 5) → 20 | Yes |
min | min(number1, number2, ...) | Smallest value | min(10, 20, 5) → 5 | Yes |
comma()rounds to at most three decimal places (comma(1234.5678)→1,234.568). Its result is text, so it cannot be used in further arithmetic.round()withoutdecimalsrounds to an integer (round(1234.5)→1235). Negativedecimalsround to tens or above (round(1234.5, -2)→1200).round()rounds.5up toward positive infinity, soround(-2.5)→-2.floor()/ceil()round to an integer; for negative numbersfloor(-3.2)→-4. To round down at a decimal place, writefloor(@price * 100) / 100.- Passing a value that is not a number fails (
comma('abc')).
Type conversion
| Function | Syntax | Description | Example → Result | Listed |
|---|---|---|---|---|
text | text(value) | Convert to text | text(123) → 123 | No |
number | number(value) | Convert to a number | number('12.5') + 1 → 13.5 | No |
number()fails for values that cannot be converted. Empty text becomes0.
Dates
| Function | Syntax | Description | Example → Result | Listed |
|---|---|---|---|---|
dateFormat | dateFormat(date, format, timezone) | Format a date as text | dateFormat(@invoiceDate, 'YYYY/MM/DD') → 2026/10/01 | Yes |
dateAdd | dateAdd(date, amount, unit, timezone) | Move a date forward or back | dateFormat(dateAdd(@invoiceDate, 30, 'days'), 'YYYY-MM-DD') → 2026-10-31 | Yes |
dateDiff | dateDiff(date1, date2, unit, timezone) | Difference between dates (date2 − date1) | dateDiff('2026-01-01', '2026-01-31', 'days') → 30 | Yes |
now | now() | The date and time of evaluation | dateFormat(now(), 'YYYY/MM/DD') | Yes |
-
Pass dates as text such as
2026-10-01. Date-times such as2026-01-15T00:30:00Zalso work. -
The timezone is optional. When omitted, the workspace setting is used, or Japan time (
Asia/Tokyo) if none is set. Specify it by name, such as'UTC'or'America/New_York'.dateFormat('2026-01-15T00:30:00Z', 'YYYY-MM-DD HH:mm') → 2026-01-15 09:30
dateFormat('2026-01-15T00:30:00Z', 'YYYY-MM-DD HH:mm', 'UTC') → 2026-01-15 00:30 -
dateAdd()andnow()return a date. Wrap them indateFormat()to display them. -
A negative
amountmoves the date back (dateAdd(@invoiceDate, -1, 'years')→ 2025-10-01). Month-end dates are clamped (one month after2026-01-31is2026-02-28). -
dateDiff()drops fractions (2026-01-31to2026-03-30is1inmonths). Swapping the dates gives a negative number. -
When the date passed to
dateFormat()is empty, the result is blank.
Units
dateAdd() / dateDiff() accept days, months, years, hours, and minutes.
Format tokens
| Token | Meaning | For 2026-10-01 |
|---|---|---|
YYYY | 4-digit year | 2026 |
M / MM | Month / zero-padded month | 10 / 10 |
D / DD | Day / zero-padded day | 1 / 01 |
H / HH | Hour (24-hour) / zero-padded | |
m / mm | Minute / zero-padded | |
GGGG | Japanese era name | 令和 |
G | Era initial | R |
y / yy | Japanese era year / zero-padded | 8 / 08 |
E | Weekday (short, Japanese) | 木 |
EEEE | Weekday (Japanese) | 木曜日 |
[...] | Output the enclosed text as is | [Issued:] YYYY/MM/DD → Issued: 2026/10/01 |
dateFormat(@invoiceDate, 'YYYY/MM/DD') → 2026/10/01
dateFormat(@invoiceDate, 'GGGGy年M月D日') → 令和8年10月1日
dateFormat(@invoiceDate, 'Gyy.MM.DD') → R08.10.01
dateFormat(@invoiceDate, 'M月D日(E)') → 10月1日(木)
For the details of the Japanese era (era boundaries, "元年"), see Template Capabilities — Japanese era.
Page numbers
| Function | Syntax | Description | Listed |
|---|---|---|---|
currentPage | currentPage() | Current page number | No |
page | page() | Same as currentPage() | Yes |
totalPages | totalPages() | Total number of pages | No |
maxPage | maxPage() | Same as totalPages() | Yes |
concat(currentPage(), ' / ', totalPages()) → 1 / 3 (page 1 of 3)
Text color
| Function | Syntax | Description | Example | Listed |
|---|---|---|---|---|
colored | colored(text, color) | Set the text color | colored(@name, '#D32F2F') | Yes |
coloredIf | coloredIf(condition, text, colorIfTrue, colorIfFalse) | Choose the text color by condition | coloredIf(@balance < 0, @balance, '#D32F2F', '#000000') | Yes |
- Write colors as
#RRGGBB(for example#D32F2F) or#RRGGBBAAwith transparency. Color names such as'red'fail. - In
coloredIf(), both colors must be valid, including the one that is not used.
Expressions that cause errors
When a formula has an error, the editor shows it and Confirm is disabled.
| Expression | Why |
|---|---|
IF(@price > 1000, 'a', 'b') | Wrong case in the function name (write if) |
comma('abc') | A value that is not a number is passed to a number function |
colored('A', 'red') | The color is not in #RRGGBB form |
max() | No arguments |
1 = 1 | There is no = operator (use == to compare) |
'unclosed text | The quote is not closed |
price | The parameter is missing its @ |
Limitations
- There is no function that sums a table column (like
SUM). Pass totals as parameters (Column totals).