Hi Alteryx Community,
I'm trying to calculate a running total of the shares outstanding after stock splits and stock conversions. I'm having difficulty coming up with a workflow that would accommodate any number of share classes, stock splits and stock conversions.
My assumption would be that I need to create running totals that essentially reset when a stock split or stock conversion occurs. However, I've hit a wall in trying to figure out how to build a workflow that does that while being flexible to incoming data.
Table 1: Stock Activity
| Date Issued | Share Class | Amount of Shares Issued |
| 1/1/2001 | Common A | 5000 |
| 1/1/2002 | Common A | 5000 |
| 1/1/2003 | Preferred A | 1,000 |
| 1/1/2004 | Preferred B | 3,000 |
Table 2: Stock Split
| Date | Share Class | Ratio (New Shares over Old shares) |
| 6/30/2001 | Common A | 2 |
| 6/30/2003 | Preferred A | 2 |
Table 3: Stock Conversion
| Date | New Share Class | Old Share Class | Ratio (New Shares over Old Shares) |
| 3/15/2004 | Common A | Preferred A | 1 |
| 3/15/2004 | Common A | Preferred B | 2 |
Desired Output:
| Date | Running Total_Common A | Running Total_Preferred A | Running Total_Preferred B |
| 1/1/2001 | 5,000 | 0 | 0 |
| 6/30/2001 | 10,000 (5,000 x 2) | 0 | 0 |
| 1/1/2002 | 15,000 (10,000 + 5,000) | 0 | 0 |
| 1/1/2003 | 15,000 | 1,000 | 0 |
| 6/30/2003 | 15,000 | 2,000 (1,000 x 2) | 0 |
| 1/1/2004 | 15,000 | 2,000 | 3,000 |
| 3/15/2004 | 23,000 (15,000 + 2,000 + 6,000) | 0 | 0 |