Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

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
6 REPLIES 6
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! :)

Gunjan_Chhabria
5 - Atom

This is really great! I've applied this to a similar use case for myself as well. However it seems to be stopping after 100 iterations. I have 9.5k+ records across 400 odd distinct IDs. Only 3 of these IDs are being combined and the remaining which is 7.5k records is flowing in the the L output of the macro i.e., is left out.

 

Is there a threshold of  some sort within the macro that I should check - I don't see any

abacon
12 - Quasar

If it is an iterative macro, you can set the max iterations. Open up the macro, go to Interface Designer, under the settings icon. You will see max iterations.

 

Bacon

 

image.png

Gunjan_Chhabria
5 - Atom

Hello, that does help I made the max limit as 20k, but now the macro takes about 3+ hours to run - is there a way to reduce time?

Gunjan_Chhabria
5 - Atom

Additionally, is there a way to join row 1 and row 3 as well i.e., we are currently having a row for 

1

1,2

1,2,3

 

But is there a possibility to joing 1,3

Labels
Top Solution Authors