Alteryx Designer Desktop Discussions

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

NEED HELP with LOOP in ADDING(SUM) of MULTIPLE COLUMNS.

iamviraj13
8 - Asteroid

Hi All,

I am new to using a LOOP in Alteryx and would need help in the below example.

I want to add columns A and B. But only want either 0 or 1 in the output and it should keep adding if the count is greater than 1 into the next column (Sum_1, Sum_2, Sum_3).

IS THIS POSSIBLE TO DO?

This is just an example and I have a file with 10k records. Any thoughts or help would be appreciated. Thank You.


iamviraj13_0-1618774354120.png

 

7 REPLIES 7
Qiu
20 - Arcturus
20 - Arcturus

@iamviraj13 

Can you elaborate your logic? I am sorry but failed to understanda it.

For examle,

what is the definition of 'Counter'?

What is the definition of "Sum_1, Sum_2, Sum_3"?

 

iamviraj13
8 - Asteroid

Hi @Qiu ,

So Column A and Column B are inputs.

Sum_1, Sum_2,Sum_3.......... are outputs

I need to add A and B. But if their sum is greater than 1 then I want the additional into next columns.

So if A+B = 3 then the output should be 1 , 1 , 1 as I only want 0 or 1 in Output column.
If A+B = 0 then it should be 0
If A+B = 2 then it should be 1 , 1.

Let me know if this is clear for you or if this is possible.


apathetichell
18 - Pollux

 

Just a quick clarification - you want the number of columns equal to the sum of a+b such that every column only has a 1 or a zero

and therefore if one A+B was equal to 7, you'd have 7 columns with 1+1+1+1+1+1+1 in each column and 0's added to any other records where there weren't 7 columns?

 

A+B = 4  1 1 1 1

A+B= 3   1 1 1 0

A+B=2    1 1 0 0

 

If I'm reading that correctly the next issue is do you want the zero columns to be on the right or on the left of the 1s?

iamviraj13
8 - Asteroid

@apathetichell Yes this is what I am looking for. 

And the order should be in the form of the input itself

like 3: 1, 1, 1, 0
      1: 1, 0, 0, 0
      0: 0, 0, 0

Qiu
20 - Arcturus
20 - Arcturus

@iamviraj13 
Thank you for the detailed information.
I think below should help and I tried to be more dynamic.

0419-iamviraj13.PNG

apathetichell
18 - Pollux

Slightly different take - note - got some weird results from generate rows so swapped to filter out the zero.

danilang
19 - Altair
19 - Altair

Hi @iamviraj13 

 

Here's a different technique.

 

danilang_0-1618839759025.png

 

The summarize tool get the largest number in the input.  This is used to generate rows from to Max for each input.  The formula tool sets the value to 1 or 0, based on the column number and sets the column name.  After removing the Sum_0 values, the values are cross tabbed to final version

 

Dan  

 

Labels