Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

StockAge FIFO

JW-ZS
7 - Meteor

Hi all,

 

I am stuck on building a solution to weekly calculate the stock age by FIFO (first-in-first-out) method for all our products (amount, days per date).

 

Example input data (note Stock minus Sell could be different from stock amount in the next row, because of depreciation or theft) :

 

ArticleDatePurchaseStockSell
9408214-3-20203003000
9408221-3-2020 3000
9408228-3-2020 2937
940824-4-2020 2858
9408211-4-2020 286-1
9408218-4-2020 2779
9408225-4-2020 26511
940822-5-2020 2632
940829-5-2020 2549
9408216-5-2020 23717
9408223-5-2020 21225
9408230-5-2020 18626
940826-6-2020 17115
9408213-6-2020 15218
9408220-6-202035349114
9408227-6-2020 45833
940824-7-2020 44019
9408211-7-2020 43110
9408218-7-2020 41417
9408225-7-2020 39915
940821-8-2020 37425
940828-8-2020 34826
9408215-8-2020 32325
9408222-8-2020 30024
9408229-8-2020 2928
940825-9-2020 2875
9408212-9-2020 2861
9408219-9-2020 2834
9408226-9-2020 285-2

 

To calculate the stock age amount and days, we have to take the Stock per certain date and look back at the last purchases (loop back) to define the stock age amount and days.

This could result in extra rows per date. So for example date 1-8-2020. Stock = 374. Look for last purchase (353 on 20-6-2020), so 353 have the age of 42 days (datediff between

Date And Last Purchase Date). For the remaining 21 we have to look back again for the next purchase (300 on 14-3-2020) and so on....

So the remaining 21 have the age of 140 days.

 

      RESULT
ArticleDatePurchaseStockSell StockAge AmountStockAge DaysDate
9408214-3-20203003000    
9408221-3-2020 3000    
9408228-3-2020 2937    
940824-4-2020 2858    
9408211-4-2020 286-1    
9408218-4-2020 2779    
9408225-4-2020 26511    
940822-5-2020 2632    
940829-5-2020 2549>>254569-5-2020
9408216-5-2020 23717    
9408223-5-2020 21225    
9408230-5-2020 18626    
940826-6-2020 17115    
9408213-6-2020 15218    
9408220-6-202035349114>>353020-6-2020
9408227-6-2020 45833 1389820-6-2020
940824-7-2020 44019    
9408211-7-2020 43110    
9408218-7-2020 41417    
9408225-7-2020 39915    
940821-8-2020 37425>>353421-8-2020
940828-8-2020 34826 211401-8-2020
9408215-8-2020 32325    
9408222-8-2020 30024    
9408229-8-2020 2928>>2927029-8-2020
940825-9-2020 2875    
9408212-9-2020 2861    
9408219-9-2020 2834    
9408226-9-2020 285-2    

 

I am not that experienced in using macro's (especially not iterative macro's), so I hope someone can help me how to start solving this.

 

Thanks in advance!

 

Kind regards,

 

Johann

4 REPLIES 4
KaneG
Alteryx Alumni (Retired)

You could definitely do this using an iterative macro but you could also do it by just using the Multi-Row. I've used a dummy text here for the date that you want the audit on. I added some data to your dataset to cater for when the StockAge went over 4 deliveries or so.

 

KaneG_0-1601622328616.png

 

 

Firstly trim the data to just what is needed and join it together to get the dataset needed for this problem

 

KaneG_1-1601622435915.png

KaneG_2-1601622478759.png

 

Then it's a matter of starting to allocate the stock on hand. Sort it descending by date, Work out the Total allocation using a Multi-Row, then tidy up and work out how many were allocated on each week. Finally work out the Age. You can probably shorten this part... there are many ways to do it (Running Total and then work out what was needed out of that total for instance).

KaneG_3-1601622612290.png

 

paulfound
11 - Bolide

Hi @JW-ZS 

 

I have created a non-macro way of creating a Stock Age monitor for you, messed around a little, so this might be good to refine further.

PaulFound_0-1601625584654.png

 

Nice challenge this. 

 

Hopefully this will get you going in the right direction.

 

Paul

 

JW-ZS
7 - Meteor

Thanks Paul and Kane! I think both flows will be helpful to start. 

 

One question though, this will work for looking back last 2 purchases, but how to solve if we have to look back for 3 or more purchases?

 

Kind regards.

 

Johann

KaneG
Alteryx Alumni (Retired)

That's why I edited your data in order to cater for more than 2 purchases. Here it is attached with the edited data. In the example used here, it only needs to go back 3 purchases, but would go back further if needed.

Labels