The intersect function allows you to find common data between two collections. This function is particularly useful when you need to compare and extract shared variables from two different collections.
Syntax
{#collection 1 | [insert filters] | intersect:collection 2:'shared unique variable'}
- Colons will separate the intersect function from the collection and the shared unique variable.
- The collection does not require single quotes while the shared unique variable does.
⚠️ The coding syntax for using the intersect function is different than other filters and functions in Athennian in that there are no single quotation marks required around the collection 2 name. This is because this function is not opening the second collection but comparing the two. |
💡 The lookup function can also be used to connect two collections. However, lookup will loop through both collections while intersect will loop through only one collection. Find out more about lookup here. [INSERT LOOKUP LINK] |
Example 1: Amalgamation
Intersect can be used for getting amalgamating company shares.
Sample Data:
Amalgamating Company #1: Accounting LLC shared unique variable: entityID - 6307a95dafa5f90a9f67ba7d |
|
Share Classes: |
Class A Common Class B Preferred |
Amalgamating Company #2: Citi Bank LLC Shared unique variable: entityID - 6307a94aafa5f90a9f67ba74 |
|
Share Classes: |
Class C Common Class D Preferred |
Desired Result:
In this case, I want to list the shareclasses of the amalgamating entities.
In the Merge/Amalgamation task, we are opening the shareclasses collection and using intersect to connect the amalgamating entities subcollection using the shared unique variable, entityID, to identify only the amalgamated entity's shareclasses then filtering out any inactive shareclasses.
Code:
{shareclasses | intersect:(tasks | grab:1:'amalgamatingEntities'):'entityID' | status:'!inactive' | toSentence:'className'}
Result:
Class A Common, Class B Preferred, Class C Common and Class D Preferred
Example 2: Dividends
In this case, we want to code a Dividends Register to show all the shareholders who have dividends in each share class. In order to have the table generate for each share class, I need to loop it through the shareclasses collection but the information in the table itself is to come from the dividends collection. To code this document, we would need to loop the table through the shareclasses collection and use the intersect function in the dividends collection and match the shared unique variable, shareclassID. This is using the intersect function as a filter, but not actually using the data. Essentially, it will only return the dividends that match the shareclass ID of the shareclass.
Dividend Register
{#shareclasses | filter:’status’:’confirmed’ | intersect:dividends:’shareclassID’}
{className} | ||||||
NAME | DATE OF RESOLUTION | DATE OF PAYMENT | PRICE PER SHARE | TOTAL AMOUNT | ||
{#dividends | orderBy_B:’recordDate’}{#dividendShareholdings}{name} | {recordDate} | {paymentDate} | {dividendPerShare} | {dividendPaid}{/} | ||
Total | {totalDividendPaid}{/} |
{@$pageBreakExceptLast}
{/}
The results returned are:
Dividend Register
Class A Common | ||||||
NAME | DATE OF RESOLUTION | DATE OF PAYMENT | PRICE PER SHARE | TOTAL AMOUNT | ||
Leslie Knope | 2023-06-17 | 2023-06-17 | $10.00 | $18,000.00 | ||
Ron Swanson | 2023-06-17 | 2023-06-17 | $10.00 | $110.00 | ||
Total | $18,110.00 |
Notes:
- The unique variable name in both collections must be identical in order to be able to open the access between Collection 1 and Collection 2.