2nd loop using increments of existing variable

Hi,

I’m trying to incorporate a second loop within my workflow that uses a specific variable (Promo_Percent) at certain levels (basically 10% increments from 0 to 100), and using those levels <=0 (all records 0%), <=10 (all records <=10%), <=20 (all records <=20%), <=30, etc. This loop would run as well as the other loop (a Group Loop - a simple regression for each combination of Brand and Region) at each Promo_Percent level, so the final output contains all combinations of Brand, Region, and Promo Percent.

How do I create the Promo loop? And which loop needs to be inside the other?

My workflow with the existing group loop is attached.

Thanks!
Loop for Promo Percent.knwf (96.9 KB)

Hi @mfreyman and welcome to the forum.

I think something like this is what you’re asking for - my added nodes are highlighted in yellow. Take a look and see if it gets you there.

Loop for Promo Percent_SF.knwf (138.7 KB)

2 Likes

Hi @ScottF,

Thanks for the welcome, and the quick, spot-on response! This is exactly what I was trying (unsuccessfully) to accomplish.

Greatly appreciated!!

2 Likes

One follow-up - how would I add a count of records/rows used for each iteration of the loops/filters?

So, when the table is compiled for all iterations (the final Loop End node), there would be a Number_Of_Records column with the number of records that were included in that particular regression run/iteration of Brand/Region/MyPerc (similar to an Iteration or MyPerc or Brand or Region value for each row).

I’ve tried adding a Math Formula ROWCOUNT variable in several areas (and also creating a new column with value of 1 and doing a Math Formula sum on that) - can’t seem to get it to appear as an option to add in the output table (Variable to Table Column node). Maybe it needs to be added as a flow variable - can’t figure that out either.

I think this is what you’re asking for - new nodes in red this time. :slight_smile:

Loop for Promo Percent_SF_2.knwf (151.5 KB)

2 Likes

Thanks again @ScottF! That does the trick nicely.

Another question - how would I change the filter to >= instead of <=? So, include only records that are greater than or equal to the promo level (instead of less than or equal).

In that case you just set the calculated flow variable that’s based on the loop iteration to govern the lower bound in the Row Filter instead of the upper bound:

1 Like

Perfect. Thanks again @ScottF!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.