Math Operations through Document Coding

  • Updated

Order of Operations

It is possible to do certain math operations using coding functions in Athennian.  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 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.

Using Math with the Count Function

A count function may be used with math operations to perform the calculation(s) specified. Please see examples in the Count with Math Operations section below.

Addition

{(collectionVariable | count)+(numerical value)}

Subtraction

{(collectionVariable | count)-(numerical value)}

Multiplication

{(collectionVariable | count)*(numerical value)}

Division

{(collectionVariable | count)/(numerical value)}

Example: Director Residency

Sample Dataset

Directors:

George Bluth (United States) - confirmed
Lucille Bluth (United States) - confirmed
Michael Bluth (Canada) - confirmed
Lucille Austero (Switzerland) - inactive
George Oscar Bluth (Canada) - outgoing

Lindsay Bluth (France) - incoming
Buster Bluth (United States) - confirmed

Complex Count & Math Operations

 

Math Operations

Input

{((directors | status:'confirmed' | filter:'taxCountry':'Canada' | count)/(directors | status:'confirmed' | count))*100}%

Order of Operations

  1. Count the number of confirmed Canadian directors
    [1]

  2. Count the total number of confirmed directors
    [4]

  3. Divide (1) by (3)
    [1/4 = 0.25]

  4. Multiply the results of (4) by 100 for a percentage of Canadian directors - [0.25*100 = 25]

Meaning

Calculate the percentage of Canadian directors by dividing the number of Canadian confirmed directors by the total number of confirmed directors, and multiplying by 100.

Output

25%