Multi Row Formula Tool - Help
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Alteryx Community
Wondering if someone can help me translate the below into the multi row formula tool?
Scenario:
Meeting morning funding requirements in accounts that have multiple people owning assets.
Formula in pseudo code:
If the cusip value meets the amount needed then use up all of that cusip and then move onto the next fund.
If the cusip value does not meet the amount needed then use up as much of that cusip as possible and then move onto another person that might have enough to cover.
Below is an example of the data. Columns 1-4 are already available and formatted using my current workflow. Columns 5-8 are pre formatted based on what I want the outcome to be.
Sleeve | Fund | Cusip | Cusip Value | Amount Needed | Result | Left Over |
Person A | Fund 1 | Cusip 1 | 100,000.00 | 50,000.00 | 50,000.00 | - |
Person B | Fund 1 | Cusip 2 | 95,000.00 | |||
Person C | Fund 1 | Cusip 3 | 85,000.00 | |||
Person D | Fund 1 | Cusip 4 | 75,000.00 | |||
Person A | Fund 2 | Cusip 1 | 100,000.00 | 300,000.00 | 100,000.00 | 200,000.00 |
Person B | Fund 2 | Cusip 2 | 100,000.00 | 200,000.00 | 100,000.00 | 100,000.00 |
Person C | Fund 2 | Cusip 3 | 100,000.00 | 100,000.00 | 100,000.00 | - |
Person D | Fund 2 | Cusip 4 | 100,000.00 |
Thank you for your time
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Mike_at_CG
I have had a look at your problem and attempted to provide a solution. Reading your post there are a couple of points I'm not quite certain on. Firstly, I don't understand the importance of the Sleeve column as the Cusip column seems to correspond directly to the sleeve column. Secondly, I made the assumption that the calculations should be grouped per Fund. If I have misunderstood please could you clarify and Ill be happy to assist further. I have attempted to solve the problem, based on my current understanding, below:
From what I could tell, column 1-4 alone wouldn't provide enough information to complete the problem. I believe you would also need a starting value for each fund. I have introduced this in the form of another table which I have then joined on to the first 4 columns. Please see the below image:
As for the rest of the solution, I have attempted to use the first 4 columns (and these fund values) to match the output.
 
I have attached a copy of the workflow below. The tools are annotated but I'm happy to expand on these if needed. Please let me know how you get on.
Regards - Pilsner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Pilsner - Thank you for this. This is exactly what I needed. After looking at the request I dont believe the column "left over" is even required. I thought that was needed in the original multi row formula tool but it seems you have baked all the logic in without the need for the additional column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Mike_at_CG - That's great to hear thank you. Glad I could help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Pilsner - Apologies for the follow up here. And I can create a new ticket for your work to get additional credit. The formula you provided me worked great for when I have 1 fund involved in the workflow. However, when there is more than 1 fund it appears to blend multiple funds together and skews the results.
Below is how the workflow is running when there are multiple funds involved.
InvestmentAccountNumber | Cusip Value | InstrumentCUSIPID | Amount Needed |
Fund 1 | 2257000 | Cusip 1 | 117000 |
Fund 1 | 1920000 | Cusip 2 | -2140000 |
Fund 1 | 500000 | Cusip 3 | -5010000 |
Fund 1 | 191000 | Cusip 4 | -5510000 |
Fund 2 | 530000 | Cusip 1 | -5806000 |
Fund 3 | 1685000 | Cusip 1 | -6336000 |
Fund 3 | 660000 | Cusip 2 | -8021000 |
Fund 3 | 265000 | Cusip 3 | -8681000 |
Fund 4 | 8017000 | Cusip 1 | -8946000 |
Fund 4 | 7000000 | Cusip 2 | -16963000 |
Fund 4 | 7000000 | Cusip 3 | -23963000 |
Fund 4 | 6580000 | Cusip 4 | -30963000 |
Fund 4 | 6500000 | Cusip 5 | -37543000 |
Below is what I call the happy path where if the amount needed is less than cusip value it uses amount needed and then completely moves on to the next fund.
InvestmentAccountNumber | Cusip Value | InstrumentCUSIPID | Amount Needed |
Fund 1 | 2,257,000.00 | Cusip 1 | 117,000.00 |
Fund 1 | 1,920,000.00 | Cusip 2 | |
Fund 1 | 500,000.00 | Cusip 3 | |
Fund 1 | 191,000.00 | Cusip 4 | |
Fund 2 | 530,000.00 | Cusip 1 | 151,000.00 |
Fund 3 | 1,685,000.00 | Cusip 1 | 151,000.00 |
Fund 3 | 660,000.00 | Cusip 2 | |
Fund 3 | 265,000.00 | Cusip 3 | |
Fund 4 | 8,017,000.00 | Cusip 1 | 146,000.00 |
Fund 4 | 7,000,000.00 | Cusip 2 | |
Fund 4 | 7,000,000.00 | Cusip 3 | |
Fund 4 | 6,580,000.00 | Cusip 4 | |
Fund 4 | 6,500,000.00 | Cusip 5 | |
Fund 4 | 6,459,000.00 | Cusip 5 |
Do you know of a way to amend the current multifield tool in order to have it generate the 2nd matrix?
Thank you for your time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Mike_at_CG
If you are aiming to replicate the second table you have provided, there are a couple of ways to do this. The easiest would be to add a formula tool at the end of the current workflow which says, if the amount needed is less than or equal to 0, then replace the value with Null()
 
Another approach uses the same idea of replacing negative values with nothing, but just builds the logic into the Multi row instead of using another tool.
I have attached a workflow which contains both of these approaches and the end result looks like this
I appreciate you may not need the "results" and " left over" column but I thought I might as well include them just in case.
I hope this helps solve your problem but please let me know if not.
Regards - Pilsner
