Order of Functions

  • Updated

In order to filter and capture the right information in your document, functions within syntax should be ‘stacked’ in a specific order. Although there are some nuances as to how to structure specific filters and functions to get the desired result, a simple way to recall the order that these should appear is as follows:

filter > uniqBy > orderBy_A / orderBy_B / sort > count / limit > upper / lower / firstCase / time

This includes pre-defined as well as ad hoc filters. For more information, please see Pre-defined and Ad Hoc Filters.

1. Filters

 

Pre-defined

Ad Hoc

Example

status:'confirmed'

filter:'taxCountry':'Canada'

 

2. UniqBy

This function removes duplicates in the collection by capturing only unique records. For more information, please see Removing Duplicates with uniqBy on filtering out duplicates.

 

uniqBy

Sample Dataset

Officers:

  • Michael Scott - President

  • Michael Scott - Chief Executive Officer

  • Jim Halpert - Vice-President

  • Pam Beesly - Secretary

  • Pam Beesly - Treasurer

Input

{#officers | uniqBy:'name' }{firstName} {/}

Meaning

List the first names of all unique officers, differentiated by name

Output

Michael Jim Pam

 

3. Sorting Functions

orderBy_A / orderBy_B / sort

These functions allows the data to be sorted, alphabetically or numerically, in ascending or descending order. For more information, please see Sorting Data: orderBy_A, orderBy_B, sort on sorting data.

 

orderBy_A

orderBy_B

sort

Sample Dataset

Nova Scotia

Manitoba

Ontario

Creed Bratton elected October 1, 2000

Stanley Hudson elected January 23, 1997

Phyllis Lapin elected July 6, 2005

Input

orderBy_A:'provinceState'

orderBy_B:'!provinceState'

sort:'electedDate'

Output

Manitoba

Nova Scotia

Ontario

Ontario

Nova Scotia

Manitoba

Stanley Hudson

Creed Bratton

Phyllis Lapin

 

4. Count / Limit

Count

This function counts the relevant data once it has been filtered and sorted. A simple count function will output a numerical value, but may also be used with logic statements or math operations. For more information, please see Counting Data on counting, Conditions: IF statements on the use of logic in conjunction with the count function, and Math Operations through Document Coding on using count in performing math operations.

 

Count

Sample Dataset

Directors:

Michael Scott (status: confirmed)
Pam Beesly (status: confirmed)
Jim Halpert (status: incoming)
Kelly Kapoor (status: inactive)

 

Input

Meaning

Output

Simple

{directors | count}

Count the number of directors

4

Filtered

{directors | status:'confirmed' | count}

Count the number of directors whose status is ‘confirmed’

2

Logic

{#directors | status:'confirmed' | count | lt:2}The sole director{/}{#directors | status:'confirmed' | count | gt:1}All of the directors{/}

Count the number of confirmed directors, and:

If there are fewer than 2, show ‘The sole director

If there are more than 1, show ‘All of the directors

All of the directors

⚠️ Sorting functions and Count should not be used in the same logic statement.

Limit

This function limits the amount of data fetched by the system. For more information, please see Limiting Data Output in a Collection on the limit function.

 

Limit

Sample Dataset

Directors:

  1. Michael Scott

  2. Pam Beesly

  3. Jim Halpert

  4. Kelly Kapoor

Input

{#directors | limit:2}{firstName } {lastName } {/}

Meaning

In the directors collection, list the first and last names of only two directors in the order they appear

Output

Michael Scott Pam

 

5. Formatting Functions

Case

This function formats the case of the variable, in either upper, lower, or first case. For more information, please see Formatting Text: upper, lower, firstCase on formatting case.

 

upper

lower

firstCase

Sample

AKNA Incorporated

Input

{entity_entityName | upper}

{entity_entityName | lower}

{entity_entityName | firstCase }

Output

akna incorporated

AKNA INCORPORATED

Akna Incorporated

Time

This function formats time and date. The default will show up in ISO format. For more information, please see Formatting Dates on formatting time.

 

Input

Output

Unformatted

2021-01-01T00 :00:00.000Z

time function only

{todaysDate | time}

2021-01-01

MMMM D, YYYY

{todaysDate | time:'MMMM D, YYYY'

January 1, 2021

[the] Do [of] MMM

{todaysDate | time:'[the] Do [of] MMM'

the 1st of Jan

 

For more information on how to stack number functions, please see Formatting Numbers: toFixed, roundNum, commaSeparate, numberConvert