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.
Last updated
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.
Last updated
For example you may have the field "Line Item Price" from your source and you would like to display the value in your document with a 10% percent tax applied. This can be calculated by multiplying (*
) the Line Item Price field by 1.1. The Tag formula to do so would look like this:
The follow arithmetic operations can can be used in Tag Formulas:
Symbol | Operation |
---|---|
Multiple operators and parentheses (
and )
can be used to make more complex expressions.
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.
The following builtin formulas exist within Portant
Formula | Description |
---|---|
Note, direct values can be used in the place of all tags and vice versa.
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.
The follow numeric aggregated formulas exits within Portant:
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.
For the line items in the table example above this would create the following result:
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:
Using one of the formulas listed below you can perform arithmetic (+
and -
) on date fields.
{{= Date + DAYS(30)}}
-> <The value will be 30 days from the value of Date
>
The formula will work with the following where N
is amount to increase by:
MINUTES(N)
HOURS(N)
DAYS(N)
WEEKS(N)
Returns the sum of a series of field values, including all field values within a Data Grouping tag.
{{=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 "}}"
The AVERAGE function returns the numerical average value in a group of tags, including all field values within a Data Group tag
{{=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 "}}"
Returns the Maximum value from a group of tags, including all field values within a Data Group tag
{{=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 "}}"
To find the Minimum value from a group of tags, including all field values within a Data Group tag
{{=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 "}}"
Rounds the numeric value of a field to a certain number of decimal places.
{{=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.
{{=ROUND(1.234, 2)}}
-> 1.23
{{=ROUND(1.234)}}
-> 1
Returns the product of two fields or numeric values. Equivalent to the `*` operator.
{{=MULTIPLY(tag1, tag2)}}
tag1
- A field containing a numeric value or a direct numeric value e.g. 6
.
tag2
- A field containing a numeric value or a direct numeric value e.g. 7
.
Returns the sum of two fields or numeric values. Equivalent to the `+` operator.
{{=ADD(tag1, tag2)}}
tag1
- A field containing a numeric value or a direct numeric value e.g. 19
.
tag1
- A field containing a numeric value or a direct numeric value e.g. 23
.
Appends strings to one another.
{{=CONCATENATE('Hello', ' ', 'World')}}
-> "Hello World"
{{=CONCATENATE(Line Item Name)}}
-> "Item AItem BItem C" (no spaces)
CONCATENATE(A2:B7)
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 amount of other fields, data grouping fields or literal strings.
Combine text of multiple fields or a data grouping field containing multiple values with a specifiable delimiter between each item.
{{=TEXTJOIN(“ | “, "Hello", "World")}}
-> "Hello | World"
{{=TEXTJOIN(“, ”, Line Item Name)}}
-> "Item A, Item B, Item C"
{{=TEXTJOIN(delimiter, tag_name_1, [tag_name_2, ...])}}
delimiter
- A string, possibly empty, or another field. If empty, text will be simply concatenated.
tag_name_1
- Any field or data grouping field from the source or a literal string in quotes.
tag_name_2, ...
- Any amount of other fields, data grouping fields or literal strings.
You can also use {{=TEXTJOINNONEMPTY(...)}} to skip empty values in the result.
Shortens the value of a field or literal text string 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"
Sum values based on a certain condition
Syntax
{{=SUMIF(Condition Tag = "Something", Numeric Data Grouped Field)}}
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
Thanks,
Blake and James
Formula | Description |
---|---|
+
Addition
*
Multiplication
-
Subtraction
/
Division
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
.
LOWER(Tag)
Converts the value of tag to lowercase text.
UPPER(Tag)
Converts the value of tag to UPPERCASE text.
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