Alteryx Designer Desktop Discussions

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

Create additional column based on conditions

terrellchong
8 - Asteroid

Hi all,

 

1st of all, Happy New Year! Wish covid goes away and may all of us resume our old lives.

 

I am trying to convert python codes from Data360 to Alteryx, encounters some hiccups and would like to ask for help

 

Below are the python code in Data360

 

 

 

#Please change formula to latest accident year - oldest accident year +1
MaxYear = 2020
MinYear = 2008
Numberyear = MaxYear - MinYear +1
#Please change Pattern to 1 for Annual; 2 for Semi-annual; 4 for Quarter; 12 for Monthly
Pattern = 1
for i in range(1,(Numberyear*Pattern)+1,1):
    check = str(i) in fields
    if check is False:
        out1[str(i)] = float
    else:
        out1[str(i)] = in1[str(i)]

 

 

 

If I would like to re-create this into alteryx, what methods can I use instead of formula tools? Please help me if can.

4 REPLIES 4
atcodedog05
22 - Nova
22 - Nova

Hi @terrellchong 

 

Can you provide some sample input and expected output(output you are getting in python). It will help us get a better understanding of the usecase.

 

We will be happy to help : )

DawnDuong
13 - Pulsar
13 - Pulsar

hi @terrellchong 

Seems like your use case involves going down an index of [1:N] to call out specific user-defined function in1 and out1.

@atcodedog05  is right, it will be easier for the community members to help if you can share the expected outputs of what this code is supposed to do with some dummy inputs.

My hunch is that you should be able to implement this code quite easily in Alteryx, but without the specifics, there is limited in what we can help.

Cheers,

Dawn.

terrellchong
8 - Asteroid

Hi @atcodedog05 , @DawnDuong ,

 

I had attached the Input and expected output file for reference.

 

Please let me know if you need more information.

 

Regards,

Terrell

atcodedog05
22 - Nova
22 - Nova

Hi @terrellchong 

 

Not sure about the purpose of the python code. Here is how you can get the expected output.

 

Workflow:

atcodedog05_0-1641042074585.png

 

You can also use Alteryx python tool to run the same python code (provided the code is complete)

https://help.alteryx.com/20213/designer/python-tool

 

Hope this helps : )

Labels