Alert: There is a planned Community maintenance outage October 16th from approximately 10 - 11 PM PST. During this time the Alteryx Community will be inaccessible. Thank you for your understanding!

Alteryx Designer Desktop Discussions

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

Loop that finds same amount but with inversed sign

rafatomillero
7 - Meteor

Hi all,

 

I have the following table

 

AB
405IIA123
2IIA123
3IIA999
-405IIA123
3IIA222
3IIA123
6IIA999
7IIA999
-6IIA999
9IIA222
6IIA999

 

and I want to create a loop that if an amount in column A is positive, for example 405 and it finds the same amount but negative and with the same value as column B it gets deleted from the data, and vice versa, i.e.: if an amount is negative it needs to find the same amount but positive and with the same value as B and delete both lines, so the table would look like this:

 

AB
  
2IIA123
3IIA999
  
3IIA222
3IIA123
  
7IIA999
  
9IIA222
6IIA999

 

Please note that I need to create a loop, and not use the Summarize tool.

 

Initially, I tried using a Multi-Row Formula:

 

IF [B] = [Row+1:B] && [A] + [Row+1:A] = 0 THEN 'Y'

ELSEIF [B] = [Row-1:B] && [A] + [Row-1:A] = 0 THEN 'Y'

ELSE 'N' ENDIF

 

Then I would filter by Equals 'N' to delete the 0 values.

 

That would have worked if the values were in order, like the table below:

 

AB
405IIA123
-405IIA123
2IIA123
3IIA999
3IIA222
3IIA123
6IIA999
-6IIA999
7IIA999
9IIA222
6IIA999

 

but unfortunately, they are not. I would like to use a similar approach.

 

Thanks in advance,

Rafa

2 REPLIES 2
apathetichell
19 - Altair

self-joins

 

basically create an offsetting field. Join the the data source twice (on the original field and the offsetting field). Look at what entries are from the right (or the left -but not the Join) anchor. Those are your unmatched entries.

binuacs
21 - Polaris

@rafatomillero One way of doing this

binuacs_0-1668110415318.png

 

Labels