Alteryx Designer Desktop Discussions

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

Offset Same amounts

BRRLL99
11 - Bolide

I have following data

 

AmountID
-400100A
-400100A
400100A
-400100A
100100A
-100100A
10100A
5100A
6100A
-6100A
-5100A
-10100A
-5100A
-5100A
5100A
99100A

 

 

I have tried this approach to get the expected output
Solved: Multi-Row level Analysis - Alteryx Community, My data has duplicates with positive and negative this approach is not working out

 

Expected output: positive number should be matched with negative number

 

AmountIDMATCH
-400100A 
-400100A 
400100AM
-400100AM
100100AM
-100100AM
10100AM
5100AM
6100AM
-6100AM
-5100AM
-10100AM
-5100A 
-5100AM
5100AM
99100A 
1 REPLY 1
Rhys_Cooper
8 - Asteroid

Hi @BRRLL99 , thank you for your quesiton - this was an interesting one to figure out. Please find my steps, screenshots and solution all below

 

Screenshot 2024-05-03 122942.png

Method:

  1.  Filter positive and minus values using
  2. Calculate absolute amount of minus values to create possible pairs with positive values
  3. Use multirow forumal on the positive set of values and negative set of values to give each independant index value. For example 5,5 would have the index of  0,1. note this is zero indexed. The purpose of adding this index is to stop an exploding join since both the value, and its correspoding index number are used in the join condition.
  4. The output left and right anchors of said join will contain values who cant pair up. this is either because there isnt enough values left to pair withit, or none at all.
  5. Use the formula tool to attach a match flag. ones which didnt join are left with a null match flag
  6. Transpose this stream so each pair gets two rows
  7. Union all streams back onto each other and add back in the ID

Note: the outputs are identifcal to your desired, but are in a slightly different order

Screenshot 2024-05-03 122843.png

 

 

any questions or adjustments (this isnt dynamic for more than one ID type) do let me know and please choose this is the solution if it was what you are after!

 

regards- Rhys Cooper

Labels