Tag Formulas

Sometimes you might need to calculate values within your document template. Within Portant you can add calculations directly within tags simply by include = at the beginning of the tag.

For example you may have the field "Line Item Price" within your workflow and you would like to include the value with a 10% percent tax. This can be calculated by multiplying (*) the Line Item Price by 1.1. The Tag formula to do so would look like this.

{{= Line Item Price * 1.1}}

Arithmetic

The follow arithmetic operations can can be used in Tag Formulas:

SymbolOperation

+

Addition

*

Multiplication

-

Subtraction

/

Division

Multiple operators and parentheses: ( and ) can be used to make more complex expressions.

Builtin Formulas

Similar to tools like Google Sheets and Excel. Certain pre-made formulas can be used within tags. For example the ROUND formula can be used to limit a numeric value to set number of decimal places.

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

The following builtin formulas exist within Portant

FormulaDescription

ROUND(Tag, [Places])

Rounds the numeric value of Tag to the number of decimal Places specified. The second variable can be omitted to round the value to a whole number.

DEFAULT(Tag, Default Value)

Provide a value to be used in the case that the value of the provided tag is blank.

ADD(Tag 1, Tag 2, [...])

Adds the numeric value of two or more tags together. This formula is the same as simply using "+".

MULTIPLY(Tag 1, Tag 2, [...])

Multiplies the numeric value of two or more tags together. This formula is the same as simply using "*".

TRUNCATE(Tag, Length)

Shortens the text based value of Tag by the specified Length.

[ ] Specifies that this paramater is optional.

Note, direct values can be used in the place of all tags and vice versa.

Aggregated Formulas

Particular builtin formulas are specifically designed to work with Data Grouping workflows in Portant and will aggregate all the grouped values of the specified tag. A particular useful formula is SUM which will add together all values for the specified tag. This is an effective way to calculate totals within your 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 follow aggregated formulas exits within Portant:

FormulaDescription

SUM(Tag)

Adds together all the values for Tag provided

PRODUCT(Tag)

Multiplies together all the values for Tag provided

AVG(Tag)

Calculated the average of all values for Tag

MAX(Tag)

Finds the largest of all values for Tag

MIN(Tag)

Finds the smallest of all values for Tag

Aggregated formulas can also be used anywhere within the document to make more complex formulas. For example you could calculate the percentage a certain Line Item Price is of the total.

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

For the line items in the table example above this would create the following result:

+-------------------+------------------------------------------------+
|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

By including the symbol | followed by the number of decimal places you would like to limit the result to an expression can be rounded similar to the ROUND formula itself.

For example we can round the following arbitrary expression to 3 decimal places like so:

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

Formula Glossary

Sum

Returns the sum of a series of field values, including all field values within a Data Group tag

{{=SUM(tag name, tag name)}}

Syntax

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

  • tag1 - The first tag to add together.

  • tag2, ... - [ OPTIONAL ] - Additional tags to add to tag1.

The tags included in the brackets don't need to be accompanied by "{{" and "}}"

Average

The AVERAGE function returns the numerical average value in a group of tags, including all field values within a Data Group tag

{{=AVG(tag name, tag name)}}

Syntax

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

  • tag1 - The first tag or Data Group tag to consider when calculating the average value.

  • tag2, ... - [ OPTIONAL ] - Additional tags to consider when calculating the average value.

The tags included in the brackets don't need to be accompanied by "{{" and "}}"

Maximum

Returns the Maximum value from a group of tags, including all field values within a Data Group tag

{{=MAX(tag name, tag name)}}

Syntax

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

  • tag1 - The first tag or Data Group tag to consider when calculating the maximum value.

  • tag2, ... - [ OPTIONAL ] - Additional tags to consider when calculating the maximum value.

The tags included in the brackets don't need to be accompanied by "{{" and "}}"

Minimum

To find the Minimum value from a group of tags, including all field values within a Data Group tag

{{=MIN(tag name, tag name)}}

Syntax

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

  • tag1 - The first tag or Data Group tag to consider when calculating the minimum value.

  • tag2, ... - [ OPTIONAL ] - Additional tags to consider when calculating the minimum value.

The tags included in the brackets don't need to be accompanied by "{{" and "}}"

Round

The ROUND function rounds a tag to a certain number of decimal places according to standard rules.

Sample usage {{=ROUND(tag name, 5)}}

{{=ROUND(tag name, tag name 2)}}

Syntax

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

  • Tag - The value to round to places number of places.

  • places - [ OPTIONAL - 0 by default ] - The number of decimal places to which to round.

Multiply

Returns the product of two tags or a tag and a number. Equivalent to the `*` operator.

{{=MULTIPLY(tag name, tag name)}}

{{=MULTIPLY(tag name,0.5)}}

Syntax

{{=MULTIPLY(tag1, tag2)}}

  • tag1 - The first multiplicand.

  • tag2 - The second multiplicand.

The tags included in the brackets don't need to be accompanied by "{{" and "}}"

Add

Returns the sum of two tags. Equivalent to the '+' operator. In Data Grouped tags the calculation occurs per row of data, NOT for all data within the group.

{{=ADD(tag name, tag name)}} {{=ADD(tag name, 5)}}

Syntax

{{=ADD(tag1, tag2)}}

  • tag1 - The first addend.

  • tag2 - The second addend.

The tags included in the brackets don't need to be accompanied by "{{" and "}}"

Truncate

Shortens the value of a tag by the specified length.

Syntax

{{=TRUNCATE(tag, length)}}

  • tag - The text to be truncated.

  • length - The number of characters to to limit the text to.

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

Example

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

Feedback and feature suggestions

We created Portant in 2021 and the feedback we have received since then has been very helpful and greatly appreciated. If you have any feedback, please feel free to send us an email at contact@portant.co or use our contact form here: https://www.portant.co/support

Thanks,

Blake and James

Last updated