cancel
Showing results for
Did you mean:

# Alteryx designer Discussions

## Logic to loop within Alteryx

Meteoroid

Hi Experts,

I am trying to implement this logic in Alteryx and not able to get perfect output as per my requirement.

Let's say I have forecasted data for 13 weeks as below:

 Week Forecast W01 13 W02 14 W03 15 W04 12 W05 15 W06 34 W07 23 W08 21 W09 23 W10 11 W11 22 W12 12 W13 10

Now based on my inventory and backlog orders I have to adjust this forecast.

For example if Total Adjustment = 20 (means I have 20 backlog orders), my forecast will change to:

 Week Forecast W01 33 13+20 W02 14 W03 15 W04 12 W05 15 W06 34 W07 23 W08 21 W09 23 W10 11 W11 22 W12 12 W13 10

But if the total adjustment = -50 (I have 50 products in my inventory) then output should be as follows

 Week Forecast W01 0 W02 0 W03 0 W04 4 W05 15 W06 34 W07 23 W08 21 W09 23 W10 11 W11 22 W12 12 W13 10

Below is the explanation to come with the output above

 Week Forecast New Expected Forecast Adjustment = Adjustment - Forecast W01 13 0 50-13=37 W02 14 0 37-14 = 23 W03 15 0 23-15=8 W04 12 4 8-12 =  -4 W05 15 15 W06 34 34 W07 23 23 W08 21 21 W09 23 23 W10 11 11 W11 22 22 W12 12 12 W13 10 10

Doing this in code is easy, we can write for or while loop, but I am unable to achieve the same in Alteryx.

Please let me know in case of any queries.

Regards,

RD

Meteoroid

Didn't get you?

Alteryx Certified Partner

Here's a possible solution that wouldn't require an iterative macro. It still may require a few tweaks, but this should, at least, get you started.

Sorry for not including any explanation... it's late in the day and heading home. If you have questions, let me know and I'll respond when possible.

Jimmy
Teknion Data Solutions

Labels