Overview

Athennian supports advanced data processing coding inside of the document to help your team produce sophisticated documents accurately and quickly. This article will cover three major operations: filters, counting and limits. These operators are added to variables in the syntax. 

Variable Filters

The variable filter enables you to filter your results for only data that you need. For example, if you want to loop the names of all transactions, but only transactions that are confirmed, and not cancelled or pending transactions, the syntax will look like this:

{#transactions | status:'Confirmed'} {shareholdingName} {/} 

Here is another example to filter for only directors whose registered address is in the city of Calgary with multiple variables:

{#directors | city:'Calgary'} {name} {address} {/}

Variable Filters: Defined and Ad Hoc

There are two ways you can filter variables. The first is using our pre-defined filters and the second is to create your own filters as needed. 

Our pre-defined filters include the following (we will update this list as we add more over time) that can be applied to any variable that has one of these attributes. You can see what variables have these attributes in the Coding Reference Guide (Link: https://goo.gl/kzBEwf). 

city
jurisdiction
lastName
firstName
country
addressType
office
title
type
status

Ad Hoc Filters

In addition to Defined filters, you can also create ad hoc filters for whatever variable you want by declaring the ad hoc filter in place of a pre-defined filter with the following syntax: "filter: {variable name}:"

For example, if you want to only list out shareholdings that have voting shares you can write that in this format:

{#shareholdings | filter:'voting':'true'} {name} {shares} {class} {/}

This statement will list all the names of the shareholdings, the amounts of shares and the classes of shares for all shareholdings that hold voting shares in the entity. 

Sort Filters

When looping data, the sort filter will let you automatically sort data alphabetically or numerically in ascending order. This is help for reports and other documents with large volumes of similar data. 

The syntax for the sort filter is:

sort:'firstName'

When used in a loop, it looks like this: 

{#directors | status:'Confirmed' | sort'firstName'}{firstName}{lastName} {/} 

If the confirmed directors are stored in Athennian in this order based on the order they were first added to the database: 

Jane
Adrian
Rebecca 

The sorting filter will organize them in the loop alphabetically in the document as follows: 

Adrian
Jane
Rebecca 

Applying the sort filter to variables that are numbers will sort those values numerically in ascending order in a loop. 

Limit Filters

The limit filter allows you to limit the number of results that Athennian prints to a document in a loop. This can be used when you only want a certain number of results in a looped table or list.

In the following example, the loop will be limited to listing 50 shareholders that are resident in the USA and sorted alphabetically by state of their address registered with the company: 

{#shareholders | country:"USA" | sort:"stateProvince" | limit:50}{firstName}{lastName} {/}

Counting

The counting operation is a powerful operation that can be used to count the number of times a specific record appears. With that number returned, we can do further calculations, automate text or just print out the number for reports. 

An obvious use case for the count function is automating pro-nouns in the text of a document depending on if there is one subject or more than one subject (e.x., directors, vendors, etc.). 

The basic syntax for counting is as follows (with directors as the example data): 

{directors | count}

Assuming there are three director records, this function will return the following value into the document: 

3

If we want to filter for any certain types of records we can add a filter as well. For example, let's assume that of the three directors, 1 is an inactive record and 2 are active confirmed records. We may only want to know the number of active directors in the company. To achieve this we would add the below filter to the count: 

{directors | status:'confirmed' | count}

This will return the following value to the document:

2


Now that we have the basics of counts, we can add some more advanced operations to automate the placement of text such as pluralizing or singularizing sentences based on the number of records.

Following the count tag, we can add the following equations:

Greater than: >
Less than: <
Equals: ==
Does not equal: != 


Because we are adding mathematical functions, we need to obey the order of operations known as BEDMAS. This requires us to add parentheses or brackets in our coding. 

For example, if we want to know if there is more than 1 confirmed director in the company we would use the following syntax:

{#(directors | status:'confirmed' | count)>1}


Think of the above syntax as an IF statement. What we are saying is that IF the number of confirmed directors in the company is greater than 1, then do THIS. We now need to give the system the instructions for what to do if this number is greater than one with the following syntax:

{#(directors | status:'confirmed' | count)>1} There is more than one director in the company {/}. 

If there is more than one confirmed director in the company, this operation will return this to the document: 

There is more than one director in the company.

Here is another example if we wanted to automate singular or plural pro-nouns for director resolutions, the syntax would look like this: 

{#(directors | status:'confirmed' | count)>1}  All the directors of the Corporation agree {/} {#(directors | status:'confirmed' | count)<2}  the sole director of the Corporation agrees {/} 

And then to include the names of the directors following the count operation, you simply include the {#directors | status:'confirmed'} {names} {/}  and Athennian will automatically lists the names of the confirmed directors. 

{#(directors | status:'confirmed' | count)>1}  All the directors of the Corporation agree {/} {#(directors | status:'confirmed' | count)<2}  the sole director of the Corporation agrees {/} {#directors | status:'confirmed'} {names} {/}

Advanced Counting Operations 

Note: This section is designed for users very comfortable with what we have learned above. 

As we learned above, we can add mathematical operations to counts in our syntax. Because Athennian's coding syntax is "Turing Complete", there is no theoretical limit to the extent of calculations we can compute. 

For example, the following syntax will calculate the percentage of directors in a company whose registered address is in Canada:

{(((directors | country:'Canada' | count) / (directors | count)) * 100)


We can then add a count feature on top of this operation to determine if the number of directors whose registered address is in Canada exceeds a certain percentage threshold to automate text with the addition of ">25" at the end of the calculation:

{#(((directors | country:'Canada' | count) / (directors | count)) * 100) > 25}

We can then add in text and a close bracket to print certain text if the percentage of directors resident in Canada exceeds our threshold of 25%: 

{#(((directors | country:'Canada' | count) / (directors | count)) * 100) > 25}25% or more of the directors in the company are resident of Canada{/}
Did this answer your question?