Skip to main content

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.

Before you start
  • 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​

  1. Select a text object and open Edit text.
  2. Switch to the Variables & formulas tab at the top.
  3. Type the formula in Formula input. The result appears under Evaluation result as you type.
  4. 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.

ParameterValue
@amount1234567
@price1200
@qty3
@name山田 太郎
@codeINV-2026-001
@invoiceDate2026-10-01
@paidfalse
@note'' (empty text)

Syntax​

WhatHow to write itExample
Parameter@parameterName@price, @customerName
Table column@tableName.columnName@items.unitPrice (the value on the current row)
Text'...' or "..."' san', "USD"
Numberdigits and a decimal point100, 0.1
Booleantrue / falsetrue
Functionname(arg, arg, ...)round(@price, 0)
Parentheses( ... )(1 + 2) * 3
  • Always prefix parameters with @. Without @ (for example price), the parameter is not referenced.
  • Function names are case-sensitive. if works; IF fails with "Unknown function: IF".
  • Numbers cannot use exponent notation (1e3) or start with a decimal point (.5); write 0.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​

KindOperatorMeaningExample → Result
Arithmetic+Add@price + 100 → 1300
Arithmetic-Subtract (also a sign, as in -@price)@price - 200 → 1000
Arithmetic*Multiply@price * @qty → 3600
Arithmetic/Divide10 / 4 → 2.5
Arithmetic%Remainder10 % 3 → 1
Comparison== / !=Equal / not equal@code == 'INV-2026-001' → true
Comparison> < >= <=Greater / less than@price > 1000 → true
LogicalandBoth true@price > 1000 and @qty < 5 → true
LogicalorEither true@price > 5000 or @qty > 1 → true
LogicalnotNegationnot @paid → true
Things to watch out for
  • + does not join text. It adds both sides as numbers ('1' + '2' → 3). Use concat() to join text.
  • == / != also compare types. The number 1 and 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). Use round() before displaying.

Order of evaluation​

Listed from first to last. Operators on the same line are evaluated left to right.

  1. Parentheses ( ... ) and functions
  2. Sign -, not
  3. * / %
  4. + -
  5. Comparisons == != > < >= <=
  6. and or
and and or have the same precedence

Unlike 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​

FunctionSyntaxDescriptionExample → ResultListed
ifif(condition, valueIfTrue, valueIfFalse)Choose a value by conditionif(@price > 1000, 'High', 'Low') → HighYes
andand(value1, value2, ...)true if all are trueand(1, true) → trueNo
oror(value1, value2, ...)true if any is trueor(0, '') → falseNo
notnot(value)Negatenot(@paid) → trueNo
isEmptyisEmpty(value)true if there is no value, whatever its typeif(isEmpty(@note), 'None', @note) → NoneYes
  • 0, empty text, and false count 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 / not operators. For joining conditions, the operator form (@a > 0 and @b > 0) is easier to read.

What isEmpty treats as "no value"​

ValueisEmpty result
A parameter with no value, or a parameter that does not existtrue
Empty text, or text that is only whitespace (half-width or full-width spaces, line breaks)true
0, false, '0', non-empty text, datesfalse
  • 0 and false count as false in an if condition, but isEmpty treats them as values. An amount of 0 gives false.
  • 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: false if the table has at least one row (even when the values are empty), and true if the table has no rows.
  • A table itself (@items) cannot be checked. It gives true even when the table has rows, so you cannot use it to check whether a table has no rows.

Text​

FunctionSyntaxDescriptionExample → ResultListed
concatconcat(value1, value2, ...)Join valuesconcat(@name, ' 様') → 山田 太郎 様Yes
lengthlength(text)Number of characterslength(@code) → 12Yes
leftleft(text, count)Characters from the startleft(@code, 3) → INVNo
rightright(text, count)Characters from the endright(@code, 3) → 001No
midmid(text, start, count)Characters from the middlemid(@code, 4, 4) → 2026No
trimtrim(text)Remove leading and trailing spacestrim(' ABC ') → ABCNo
upperupper(text)Uppercaseupper('abc') → ABCNo
lowerlower(text)Lowercaselower('ABC') → abcNo
replacereplace(text, search, replacement)Replace textreplace(@code, '-', '/') → INV/2026/001No
replaceAllreplaceAll(text, search, replacement)Same as replacereplaceAll(@code, '-', '') → INV2026001No
  • concat() turns numbers and booleans into text as they are (concat('a', 1, true) → a1true).
  • The start of mid() is zero-based (the first character is 0).
  • right(text, 0) returns the whole text.
  • replace() replaces every occurrence. The search text is matched literally (not as a regular expression).

Numbers​

FunctionSyntaxDescriptionExample → ResultListed
commacomma(number)Add thousands separatorscomma(@amount) → 1,234,567Yes
roundround(number, decimals)Round half upround(1234.567, 2) → 1234.57Yes
floorfloor(number)Round down to an integerfloor(1234.5) → 1234Yes
ceilceil(number)Round up to an integerceil(1234.1) → 1235Yes
absabs(number)Absolute valueabs(-10) → 10Yes
maxmax(number1, number2, ...)Largest valuemax(10, 20, 5) → 20Yes
minmin(number1, number2, ...)Smallest valuemin(10, 20, 5) → 5Yes
  • 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() without decimals rounds to an integer (round(1234.5) → 1235). Negative decimals round to tens or above (round(1234.5, -2) → 1200).
  • round() rounds .5 up toward positive infinity, so round(-2.5) → -2.
  • floor() / ceil() round to an integer; for negative numbers floor(-3.2) → -4. To round down at a decimal place, write floor(@price * 100) / 100.
  • Passing a value that is not a number fails (comma('abc')).

Type conversion​

FunctionSyntaxDescriptionExample → ResultListed
texttext(value)Convert to texttext(123) → 123No
numbernumber(value)Convert to a numbernumber('12.5') + 1 → 13.5No
  • number() fails for values that cannot be converted. Empty text becomes 0.

Dates​

FunctionSyntaxDescriptionExample → ResultListed
dateFormatdateFormat(date, format, timezone)Format a date as textdateFormat(@invoiceDate, 'YYYY/MM/DD') → 2026/10/01Yes
dateAdddateAdd(date, amount, unit, timezone)Move a date forward or backdateFormat(dateAdd(@invoiceDate, 30, 'days'), 'YYYY-MM-DD') → 2026-10-31Yes
dateDiffdateDiff(date1, date2, unit, timezone)Difference between dates (date2 − date1)dateDiff('2026-01-01', '2026-01-31', 'days') → 30Yes
nownow()The date and time of evaluationdateFormat(now(), 'YYYY/MM/DD')Yes
  • Pass dates as text such as 2026-10-01. Date-times such as 2026-01-15T00:30:00Z also 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() and now() return a date. Wrap them in dateFormat() to display them.

  • A negative amount moves the date back (dateAdd(@invoiceDate, -1, 'years') → 2025-10-01). Month-end dates are clamped (one month after 2026-01-31 is 2026-02-28).

  • dateDiff() drops fractions (2026-01-31 to 2026-03-30 is 1 in months). 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​

TokenMeaningFor 2026-10-01
YYYY4-digit year2026
M / MMMonth / zero-padded month10 / 10
D / DDDay / zero-padded day1 / 01
H / HHHour (24-hour) / zero-padded
m / mmMinute / zero-padded
GGGGJapanese era name令和
GEra initialR
y / yyJapanese era year / zero-padded8 / 08
EWeekday (short, Japanese)木
EEEEWeekday (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​

FunctionSyntaxDescriptionListed
currentPagecurrentPage()Current page numberNo
pagepage()Same as currentPage()Yes
totalPagestotalPages()Total number of pagesNo
maxPagemaxPage()Same as totalPages()Yes
concat(currentPage(), ' / ', totalPages())   → 1 / 3 (page 1 of 3)

Text color​

FunctionSyntaxDescriptionExampleListed
coloredcolored(text, color)Set the text colorcolored(@name, '#D32F2F')Yes
coloredIfcoloredIf(condition, text, colorIfTrue, colorIfFalse)Choose the text color by conditioncoloredIf(@balance < 0, @balance, '#D32F2F', '#000000')Yes
  • Write colors as #RRGGBB (for example #D32F2F) or #RRGGBBAA with 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.

ExpressionWhy
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 = 1There is no = operator (use == to compare)
'unclosed textThe quote is not closed
priceThe parameter is missing its @

Limitations​

  • There is no function that sums a table column (like SUM). Pass totals as parameters (Column totals).