Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

FIFO Iterative Macro - Solve for the Remainder

jvalcareng002
6 - Meteoroid

I have been working on an iterative macro to solve a FIFO logic scenario. The idea is that each quantity ordered is consumed by each quantity delivered in a time series order from the first quantity ordered (determined by the first invoice order date).

 

This workflow reconciles 2 inputs (1 for date / quantity ordered, and 2 for date / quantity delivered) based on customer id and product type ("New Item"), and it has three outputs as follows:

 

Output I: Quantity Ordered is greater than Quantity Delivered - The difference between Quantity Ordered and Quantity Delivered is positive. Output I is rerun through the iterative macro up until all iterations are run and the remaining excess of Quantity Ordered over Quantity Delivered is output.

 

Output O: FIFO Output: For all matches between the two inputs based on customer id and product type, the FIFO output includes the total Quantity Delivered up until the total Quantity Ordered is consumed. 

 

Output E: Quantity Ordered is less than Quantity Delivered - The difference between Quantity Ordered and Quantity Delivered is negative. This is the case where we have inadvertently sent more product than the customer ordered (not an ideal situation), or the customer id or product type do not match. 

 

jvalcareng002_0-1613751667151.png

 

Output E is the output that is giving me trouble. Currently, I am getting a partial remainder, but somewhere along the way some part of the total difference between quantity ordered and quantity delivered is not flowing through. This means that if there are 3 items in an order and 10 are delivered, then the 3 that are consumed are included in Output O, and the 7 remaining do not flow through.

 

Refer to the example below:

 

Input 1: 

customer_idcustomerNew ItemEffective RateInvoice Order WeekOrder Quantity
10024Customer1329At Home Test11912/28/20201
10024Customer1329At Home Test1191/25/20214

 

Input 2: 

customer_idcustomerNew ItemDelivered WeekQuantity Delivered
10024Customer1329At Home Test11/30/20201
10024Customer1329At Home Test12/28/20201
10024Customer1329At Home Test1/4/20211
10024Customer1329At Home Test1/18/20211
10024Customer1329At Home Test1/25/20212
10024Customer1329At Home Test2/1/20213

 

Output O:

customer_idcustomerNew ItemInvoice Order WeekDelivered Week# From Order Created on This DateEffective Rate
10024Customer1329At Home Test12/28/202011/30/20201119
10024Customer1329At Home Test1/25/202112/28/20201119
10024Customer1329At Home Test1/25/20211/4/20211119
10024Customer1329At Home Test1/25/20211/18/20211119
10024Customer1329At Home Test1/25/20211/25/20211119

 

Output E - output E should appear as shown below:

 

customer_idcustomerNew ItemDelivered Week# From Order Created on This Date
10024Customer1329At Home Test1/25/20211
10024Customer1329At Home Test2/1/20213

 

Output E - however, the result I am getting for output E is missing a record, as shown below:

 

customer_idcustomerNew ItemDelivered Week# From Order Created on This Date
10024Customer1329At Home Test2/1/20213

 

 

I have attached the macro and an example workbook below to show the correct output. 

 

 

 

 

1 REPLY 1
EricWe
Alteryx
Alteryx

Hi @jvalcareng002

 

It appears that a formula may be needed after the Join tool's R output anchor. It may be possible to calculate all ordered and delivered quantities with a set of formulas such as the examples pictured from a workflow attached to this training session: Advanced Macro Development. New columns are used to calculate if the demand at each location was fulfilled and if there is remaining supply or demand based on the starting inventory.

 

formulas.PNG

Labels