# Math Operations through Document Coding Doc Auto Team
• Updated

It is possible to do certain math operations using coding functions in Athennian. The data must be number-type in order for math operations to be performed through coding. Since functions such as `count` and `sum` result in a number-type value, math can be performed with the byproducts of the `count` and `sum` functions as well.

# Order of Operations

There’s no limit to the number of operations specified, but the order of operations must adhere to BEDMAS/PEMDAS structure, and use the appropriate mathematical symbol(s). This may require additional parentheses inserted into the code to capture the correct order of operations. Common uses of math operations include, but are not limited to, share price calculations, or residency requirements (percentage of directors).

 Order of Operations (BEDMAS / PEMDAS) Symbol Brackets / Parentheses ( ) Exponents* Division / Multiplication * Addition + Subtraction -
*This is not used within Athennian, and is only presented for reference to the mathematical order of operations.

# Syntax

 Sample Shareholdings Data Fiona Forrest holds 100 Common shares bought at \$1.00 per share Gemma Germinate holds 50 Common shares bought at \$1.00 per share Herbert Horticulture holds 100 Common shares bought at \$1.00 per share Isabella Iridescence holds 25 Common shares bought at \$1.00 per share Julian Juniper holds 10 Common shares bought at \$1.00 per share

Note: In the following code snippets of syntax, `{which will appear like so}`, we will use the multiplication symbol (*) to represent any of the math symbols, depending on what operations need to be performed.

## Using Simple Math

`{#collectionVariable}{numberVariable*numberVariable}{/}`

Having opened the target collection, insert the correct math symbol between the two number-type variables.

To get a simple list of aggregate consideration, multiply the number of shares held by each shareholder by the price paid per share.

 Input Output {#transactions}{shareholdingName}(\${numShares*pricePerShare}){/} Fiona Forrest (\$100) Gemma Germinate (\$50) Herbert Horticulture (\$100) Isabella Iridescence (\$25) Julian Juniper (\$10)

## Using Math with sum Function

`{collectionVariable | sum:'numberVariable*numberVariable'}`

The `sum` function is not only able to add up single number-type variables within the same collection, it is also able to add up number-type products of math operations. For more information on summing up values, check out Getting an Aggregate Amount using Sum.

To get a list of aggregate considerate of all transactions, we may sum up the product of all of the shareholder's considerations as calculated above.

 Input Output The total consideration paid is \${transactions | sum:'numShares*pricePerShare'}. The total consideration paid is \$285.

## Using Math with count Function

`{(collectionVariable | count)*number}` or

`{(collectionVariable | count)*numberVariable}` or

`{(collectionVariable | count)*(collectionVariable | count)}`

Since the `count` function results in a numerical value (aka number-type data), it may be used with math symbols to perform the calculation specified. For more information on the `count` function, check out the Counting Data article.

 Sample Share Classes Data Common - voting Class A Special - non-voting Class A Common - voting Class B Special - non-voting Class B Common - voting Class C Special - non-voting Class C Common - voting Preferred - non-voting

To calculate the ratio of voting share classes, divide the count of voting share classes by the total count of all share classes.

 Input The ratio of voting share classes is {(shareclasses | filter:'votingRights':'true' | count)/(shareclasses | count)}. Calculations Count the number of voting share classes{shareclasses | filter:'votingRights':'true' | count} = 4 Count the total number of all share classes{shareclasses | count}= 8 Divide the number of voting classes by all classes for the ratio{(shareclasses | filter:'votingRights':'true' | count)/(shareclasses | count)}= {4/8}= 0.5 Output The ratio of voting share classes is 0.5.

## Mixed Operations

To calculate the percentage of non-voting share classes, divide the count of non-voting share classes by the total count of all share classes, then multiply by a numerical value of 100 to get the percentage.

 Input The percentage of non-voting share classes is {((shareclasses | filter:'votingRights':'!true' | count)/(shareclasses | count))*100}%. Calculations Count the number of non-voting share classes{shareclasses | filter:'votingRights':'!true' | count} = 4 Count the total number of all share classes{shareclasses | count}= 8 Divide the number of non-voting classes by all classes for the ratio{(shareclasses | filter:'votingRights':'!true' | count)/(shareclasses | count)}= {4/8}= 0.5 Multiply the ratio by 100 for the percentage{((shareclasses | filter:'votingRights':'!true' | count)/(shareclasses | count))*100}= {0.5*100}= 50 Output The ratio of voting share classes is 50%.