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.

Grouping numbers by a list of given value

Paddi
8 - Asteroid

Hi,

 

Is it possible to group a list of numbers by specific given value?

 

For each account (AAA), there will be 2 or more numbers as grouping reference (600,900), the alteryx tool need to decide from input 1 that how should (100,200,300,400,500) be grouped to 600 and 900.

 

For example, give 600 and 900, 100,200,300,400,500 would be grouped to

100+200+300 =600

400+500 =900

 

Detailed data, number, output as attached:

 

Input1: Data to be grouped

 
Account Value DateAmount
AAA12/1/2023100
AAA12/1/2023200
AAA12/1/2023300
AAA12/1/2023400
AAA12/1/2023500
BBB12/2/2023100
BBB12/2/2023200
BBB12/2/2023300
BBB12/2/2023400
BBB12/2/2023500
BBB12/2/2023250
BBB12/2/2023210
BBB12/2/2023110
BBB12/2/2023190

 

Input2: grouping reference

Account Value DateGoal
AAA12/1/2023600
AAA12/1/2023900
BBB12/2/20231750
BBB12/2/2023510

 

Output:

 

Account Value DateAmountGoal
AAA12/1/2023100600
AAA12/1/2023200600
AAA12/1/2023300600
AAA12/1/2023400900
AAA12/1/2023500900
BBB12/2/20231001750
BBB12/2/20232001750
BBB12/2/20233001750
BBB12/2/20234001750
BBB12/2/20235001750
BBB12/2/20232501750
BBB12/2/2023210510
BBB12/2/2023110510
BBB12/2/2023190510
4 REPLIES 4
apathetichell
20 - Arcturus

can you use words to describe the logic which you are using to aggregate your values? I don't see it.

Paddi
8 - Asteroid

Hi @apathetichell ,

 

I have updated the logic in words, hope it helps. Kindly let me know if any questions.

CoG
14 - Magnetar

@Paddi 

The difficulty with this problem is 2 fold, there may be many occasions where multiple solutions exist. How do you handle this? For example, with the input provided:

100+500 = 600

200+300+400 = 900

-OR-

100+200+300 = 600

400+500 = 900

How do you know which to assign? The second issue is more pragmatic. What you are looking for is a solution to a partition problem, which involves permutations, of which there can be many possibilities. Just for the input you provided, there are 540 different ways to group amounts together. Solving this problem can get very big very quickly, which can be slow to run or crash completely.

 

That being said, if precise grouping doesn't matter, then here is a workflow that does what you're looking for:

_Main Workflow.png

 

There is a macro included (not pictured here for brevity's sake) that computes all possible partitions.

apathetichell
20 - Arcturus

is this a number theory experiment? What's the context here? As @CoG succinctly pointed out - and I ambigously referenced - your rules do not work because there are multiple potential combinations.  You can try to experiment using the optimizatoin tool for some of this stuff. But I'm not really sure what you're looking to do based upon your descriptoin.

Labels
Top Solution Authors