Alteryx Designer Desktop Discussions

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

Flag the items the value of which sums up to zero in two files

45179902
8 - Asteroid

I have a dataset from two files A and B. I want to flag the ID with values that add up to 0 in the two files.

 

Here is an example of the dataset.

CardIDAmountTimeFile
2023012023-01500012:00A
2023022023-0220012:50A
2023-012023-01-500012:00B
2023-022023-0215012:50B
2023-012023-0125016:00B

 

The desired output would be:

CardIDAmountTimeFileFlag
2023012023-01500012:00AYes
2023022023-0220012:50ANo
2023-012023-01-500012:00BYes
2023-022023-0215012:50BNo
2023-012023-0125016:00BYes

 

Note that ID 2023-01 is flagged Yes because 5000 from file A plus -5000 in file B equals to zero. The additional record in file B with a value of of 250 is flagged Yes as well. ID 2023-02 is flagged No because there's no value in the two files follow this rule.

6 REPLIES 6
Yoshiro_Fujimori
15 - Aurora

Hi @45179902 ,

 

I hope below fits your requirement.

 

Workflow

Yoshiro_Fujimori_0-1682754786766.png

 

Output

Yoshiro_Fujimori_1-1682754806167.png

 

45179902
8 - Asteroid

Hi @Yoshiro_Fujimori Thanks for your help! After checking the data, I see cases of an ID having both values that add up to 0 and not to 0. In this case, I would like to flag these items as Yes even though it doesn't completely follow the rule.

 

Below is an updated example. Could you help me modify the workflow so that it achieves this new desired outcome?

 

IDAmountFile
2023-015000A
2023-02200A
2023-01-5000B
2023-02150B
2023-01150B

 

Output:

IDAmountFileFlag
2023-015000AYes
2023-02200ANo
2023-01-5000BYes
2023-02150BNo
2023-01250BYes

Notice that ID 2023-01 now has values that add up to 0 in files A and B (5000 in A + -5000 in B = 0) and an additional record in file B with the value of 250 which doesn't result in 0 (5000 + 250 = 5250). In this case, I would like to flag this item as Yes as well because in the previous case of ID 2023-01, it works.

 

Thanks~

45179902
8 - Asteroid

Hi @Yoshiro_Fujimori Thanks for your effort! It's odd that I can't find my reply to you after refreshing the page, so I'm typing again here. After checking the data, I found that there're cases in which an ID could have values that add up to or not to 0. In this case, as long as there're values that add up to 0, I would like to flag the ID as "Yes".

 

Below is my updated example:

CardIDAmountTimeFile
2023012023-01500012:00A
2023022023-0220012:50A
2023-012023-01-500012:00B
2023-022023-0215012:50B
2023-012023-0125016:00B

 

The new desired output would be:

CardIDAmountTimeFileFlag
2023012023-01500012:00AYes
2023022023-0220012:50ANo
2023-012023-01-500012:00BYes
2023-022023-0215012:50BNo
2023-012023-0125016:00BYes

Note that ID 2023-01 is flagged Yes because 5000 from file A plus -5000 in file B equals to zero. The additional record in file B with a value of 250 is flagged Yes as well.

Yoshiro_Fujimori
15 - Aurora

@45179902 ,

 

I am not sure what you mean by 

"an ID could have values that add up to or not to 0.

"In this case, as long as there're values that add up to 0, I would like to flag the ID as "Yes"

Once the running total adds up to 0, the ID should be flagged as "Yes" for all the rows?

If that is the case, here is one way of doing this.

 

Workflow

Yoshiro_Fujimori_0-1682767600312.png

 

Output

Yoshiro_Fujimori_1-1682767621315.png

 

45179902
8 - Asteroid

@Yoshiro_Fujimori Thanks for your update. Running total is a tool that I've not used before. This is an interesting solution to the challenge. Your interpretation of the two quoted lines is correct. Unfortunately, after checking the data, I found out this workflow would miss flagging some items. I believe it's due to the sorting of time. Some + and - records in the two files after sorting are still not adjacent to each other; and therefore, failed to result in 0.

 

As can be seen from the given example, there could be different numbers of the same variable 2023-01 in files A and B, meaning that there could be just one 2023-01 in file A but two or three in file B. I still can't find a way to properly flag those that cancel out after adding together. My goal remains to find out the variables in file A that has a positive number which after summing up with the negative number of the same variable in file B would result in 0. 

Yoshiro_Fujimori
15 - Aurora

@45179902 ,

Could you give me sample data set where the workflow doesn'twork?

 

Labels