Portant Portant Docs

Tag formulas

Tag formulas let you do maths, format dates, build text, and aggregate values inside a tag. They use the same {{ }} syntax as a normal tag, but start with = to mark them as a formula.

For example, if your source has a Line Item Price field and you want to display the price with 10% tax added, multiply the field by 1.1:

{{= Line Item Price * 1.1}}

Tag formula evaluated inside a Portant document template

Arithmetic

You can use these arithmetic operators in tag formulas:

Symbol Operation
+ Addition
* Multiplication
- Subtraction
/ Division

You can combine multiple operators and use parentheses ( ) to build more complex expressions.

Built-in formulas

Like Google Sheets and Excel, Portant has a set of built-in formulas you can call inside a tag. For example, ROUND limits a numeric value to a set number of decimal places:

{{Line Item Price}} -> 24.1234
{{=ROUND(Line Item Price, 2)}} -> 24.12
{{=ROUND(Line Item Price)}} -> 24

These built-in formulas are available:

Formula Description
ROUND(Tag, [Places]) Rounds the numeric value of Tag to Places decimal places. Omit the second argument to round to a whole number.
DEFAULT(Tag, Default Value) Use a fallback value when the tag is blank.
ADD(Tag 1, Tag 2, [...]) Adds two or more numeric tags together. Same as using +.
MULTIPLY(Tag 1, Tag 2, [...]) Multiplies two or more numeric tags together. Same as using *.
TRUNCATE(Tag, Length) Shortens the text value of Tag to the specified Length.
LOWER(Tag) Converts the value of Tag to lowercase text.
UPPER(Tag) Converts the value of Tag to UPPERCASE text.

[ ] means the parameter is optional.

You can pass literal values in place of tags (and tags in place of values) anywhere in a formula.

Numeric

Aggregated formulas

Some built-in formulas are designed to work with data grouping workflows and aggregate all the grouped values for a tag. The most common is SUM, which adds together every value for a given tag. It's the easiest way to calculate a total inside a template.

Within a Data Grouping Table:
+-----------------------------+
|1. {{Line Item Price}} -> 10 |
+-----------------------------+
|2. {{Line Item Price}} -> 20 |
+-----------------------------+
|3. {{Line Item Price}} -> 30 |
+-----------------------------+

{{=SUM(Line Item Price)}} -> 60

The numeric aggregated formulas are:

Formula Description
SUM(Tag) Adds together all values for Tag.
PRODUCT(Tag) Multiplies together all values for Tag.
AVG(Tag) Calculates the average of all values for Tag.
MAX(Tag) Returns the largest value for Tag.
MIN(Tag) Returns the smallest value for Tag.

You can use aggregated formulas anywhere in the document, including inside more complex expressions. For example, to calculate what percentage a single line item is of the total:

{{= (Price / SUM(Price)) * 100 | 2}}%

For the line items in the table above, this produces:

+-------------------+------------------------------------------------+
|1. {{Price}} -> 10 | {{= (Price / SUM(Price)) * 100 | 2}}% -> 0.16% |
+-------------------+------------------------------------------------+
|2. {{Price}} -> 20 | {{= (Price / SUM(Price)) * 100 | 2}}% -> 0.33% |
+-------------------+------------------------------------------------+
|3. {{Price}} -> 30 | {{= (Price / SUM(Price)) * 100 | 2}}% -> 0.50% |
+-------------------+------------------------------------------------+

Decimal place modifier

Add | followed by a number at the end of an expression to round the result to that many decimal places, the same way ROUND does. For example, to round an arbitrary expression to 3 decimal places:

{{1.1234 + 1.0 | 3}} -> 2.123

Date and time formatting

Format any date or timestamp using the FORMATDATE formula. This gives you full control over how dates appear in your generated documents.

Basic usage

Use the formula inside a tag:

{{=FORMATDATE(Timestamp, "DD/MM/YYYY")}}

The first parameter is your date field. The second parameter is the output format.

Formatting tokens

Token Output examples
D 1, 19
DD 01, 19
M 1, 12
MM 01, 12
MMM Jan, Dec
MMMM January, December
YY 25
YYYY 2025

Example formats

Format Output example
"DD/MM/YYYY" 07/02/2025
"MMM D, YYYY" Feb 7, 2025
"MMMM DD" February 07
"YY-MM-DD" 25-02-07

Date and time arithmetic

You can add or subtract time from a date field using these helpers:

{{= Date + DAYS(30)}} returns a value 30 days after the value of Date.

The supported units (where N is the amount to add or subtract) are:

  • MINUTES(N)
  • HOURS(N)
  • DAYS(N)
  • WEEKS(N)

Formula glossary

Sum

Returns the sum of a series of field values, including all field values within a data grouping tag.

Syntax

{{=SUM(tag1, tag2, ...)}}

  • tag1: The first tag to add together.
  • tag2, ... (optional): Additional tags to add to tag1.

Tags inside the brackets don't need {{ and }} around them.

Average

AVG returns the numerical average of a group of tags, including all field values within a data group tag.

Syntax

{{=AVG(tag1, tag2, ...)}}

  • tag1: The first tag or data group tag to include in the average.
  • tag2, ... (optional): Additional tags to include.

Maximum

Returns the largest value from a group of tags, including all field values within a data group tag.

Syntax

{{=MAX(tag1, tag2, ...)}}

  • tag1: The first tag or data group tag to consider.
  • tag2, ... (optional): Additional tags to consider.

Minimum

Returns the smallest value from a group of tags, including all field values within a data group tag.

Syntax

{{=MIN(tag1, tag2, ...)}}

  • tag1: The first tag or data group tag to consider.
  • tag2, ... (optional): Additional tags to consider.

Round

Rounds the numeric value of a field to a certain number of decimal places.

Syntax

{{=ROUND(tag, [places])}}

  • tag: The value to round.
  • places (optional, 0 by default): The number of decimal places to round to.

Sample usage

{{=ROUND(1.234, 2)}} -> 1.23

{{=ROUND(1.234)}} -> 1

Multiply

Returns the product of two fields or numeric values. Same as the * operator.

Syntax

{{=MULTIPLY(tag1, tag2)}}

  • tag1: A field with a numeric value or a literal number (e.g. 6).
  • tag2: A field with a numeric value or a literal number (e.g. 7).

Add

Returns the sum of two fields or numeric values. Same as the + operator.

Syntax

{{=ADD(tag1, tag2)}}

  • tag1: A field with a numeric value or a literal number (e.g. 19).
  • tag2: A field with a numeric value or a literal number (e.g. 23).

Text

Concatenate

Joins strings together.

Sample usage

{{=CONCATENATE('Hello', ' ', 'World')}} -> "Hello World"

{{=CONCATENATE(Line Item Name)}} -> "Item AItem BItem C" (no spaces)

CONCATENATE(A2:B7)

Syntax

CONCATENATE(tag_name_1, [tag_name_2, ...])

  • string1: Any field or data grouping field from the source, or a literal string in quotes.
  • string2 ...: Any number of other fields, data grouping fields, or literal strings.

Text join

Combines text from multiple fields, or from a data grouping field with multiple values, with a delimiter between each item.

Sample usage

{{=TEXTJOIN(" | ", "Hello", "World")}} -> "Hello | World"

{{=TEXTJOIN(", ", Line Item Name)}} -> "Item A, Item B, Item C"

Syntax

{{=TEXTJOIN(delimiter, tag_name_1, [tag_name_2, ...])}}

  • delimiter: A string (which can be empty) or another field. If empty, the values are simply concatenated.
  • tag_name_1: Any field or data grouping field from the source, or a literal string in quotes.
  • tag_name_2, ...: Any number of other fields, data grouping fields, or literal strings.

You can also use {{=TEXTJOINNONEMPTY(...)}} to skip empty values in the result.

Truncate

Shortens the value of a field or literal string to a given length.

Syntax

{{=TRUNCATE(tag, length)}}

  • tag: The text to truncate.
  • length: The number of characters to keep.

If length is greater than the number of characters in the value, the value is returned unchanged.

Example

{{Message}} -> "Hello World"

{{=TRUNCATE(Message, 5)}} -> "Hello"

Filter and sum (SUMIF)

Sum values that match a condition.

Syntax

{{=SUMIF(Condition Tag = "Something", Numeric Data Grouped Field)}}

For more on conditions inside tags, see tag if statements.