Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Sum all possible combinations then match against a value

Davonalt
7 - Meteor

Hi

 

I hope the following make sense.

 

I hope the following makes sense. So I want to sum all the possible combinations the amount below, Per id then type.

 

 
idTypeAmount
1a10
1b20
1c30
1d40
2a30
2b10
2c50
2d70

 

 

So something like:-

idComboSum amount Amount
1a+b+c+d100
1a+b+c60
1a+b30
1a10
1a+d50
1b+c50

An so on...

 

Then if the below matches with in 1 either way then return the combo’s that match

 

idAmount
150.50
2120.49
2 REPLIES 2
TimN
13 - Pulsar
rzdodson
12 - Quasar

@Davonalt built a nested iterative macro approach for you. Was not exactly sure what you meant by the "Then if the below matches with in 1 either way then return the combo’s that match" statement. However, if you open the first iterative macro and go to Filter (21), I simply used the amounts from your last list to test whether each permutation from that ID group is less than or equal to its threshold for that group (ID 1 <=50.50).

 

Inner most layer of nested iterative macro.

Explanation: This layer iterates through the Iter field (Row 1, Row1 + Row2, Row 1+Row2+Row3), creates the permutation you are looking for in the Type field, and then sums the values from each letter. The output from this layer gives you all permutations of that Type group and their associated values that are summed.

Solution3.png

 

First layer of nested iterative macro

Explanation: This layer iterates through each ID group, gets the values from all permutations, and then filters based on the your last table. If you need to change the threshold logic as mentioned above, the last Filter tool is where I would draw your attention.

Solution2.png

 

 

Outer most layer of workflow

Explanation: Adding a RecordID tool establishes the critical Iter field we need to support the nested iterative macro setup.

Solution1.png

 

Hope this gets you close to what you need! :)

Labels