community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Creating a field

Highlighted
Asteroid

Please see attached file for visual demonstration.

 I have two files:

1. has keycodes for my campaign with customers who received the campaign

2. has purchases that were between certain time period (these include people who may or many not be in the campaign file)

 I joined these two. I got the joins and it's all good.  BUT now I want to do some predictive analytics on this.  To do that I need to have binary field 'yes' or 'no' to determine if someone made a purchase or not and that is based on 'this customer was sent an email and he/she made a purchase so say 'yes' or vice-versa'.

 I thought that I could create a field in the workflow that says 'yes' or 'no' rather than taking the files into excel and then doing the manual additional of a colum etc. etc. for all these files. 

 Is it possible to do what I am asking for or do I need to take the files into excel and then add the response?

 

Is this clear or should I give more information?

 

Thank you

 

Aman

ACE Emeritus
ACE Emeritus

If i'm understanding you correctly you want a new field that is just a binary "yes" or "no" based upon some logic?

 

if so that is very doable. You would simply add a Formula tool.

 

make a new field that is a "Bool" output type.  Then you would put your logical if condition in your workflow.....

 

So for example if your logic was "if customer was sent email and customer made purchase then yes else no"  

 

Then in your formula tool in the "expression" box you would put.

 

If {Field 1 customer sent email}=1 and {Field 2 customer made purchase}=1 then 1 else 0 endif.

 

This will create the new binary field in your workflow. No need to get excel involved at all...

 

Let me know if I am not understanding you fully.

Asteroid

Ok. will try this.  will it create a field also?  This means I do not need to use 'Generate Rows' tool then.

ACE Emeritus
ACE Emeritus

I actually don't know what the 'generate rows' tool is haha.  But yes the formula tool is used to create new columns or to update existing ones.

 

If you want to test it add a new column named "Test" with a type of V_WString and in the expression box put in "This is a test column".

 

This will give you a brand new column named "Test" with the values "this is a test column" and it will populate for every row of data you have on your flow up until that point :-)

 

Is this what you needed?

Asteroid

So, I have come against something not so fun.

 

If you see the word document that I attached, there is the Left join that has all the people who didn't purchase, the middle 'Join' has everything that joined from my two original files and then the R is all the people who didn't join either so basically were not part of the 'Join' or purchased but weren't sent the email.

I just want to add 'yes' and 'no' to these separately.

Alteryx Alumni (Retired)

The Generate Rows tools does basically what is says...generate Rows (as opposed to a new field which is done typically with the Formula tool...although there are other tools like the Multi-Field and Multi-Row Formula tools that can also create new fields for specific reasons).

The Generate Rows tool is primarily when you are wanting to create a set of records that might be missing (for example, a record for each date in the year) and you want to "fill in the blanks". Or another case is when you have no data but want to work with some records of data for testing a workflow, it is a quick way to generate some random numbers (but again, you would generate the rows with the Generate Rows tool, and the extra fields with the Formula tool).

Hope this helps...

Bolide

Hi akaur! Just add a formula tool to each of the 3 outputs from the Join. Make sure you give your new field the same name in each of the new Formula tools! Define your Yes and No in each as appropriate and then use the Union tool to bring all three pieces back together!

Asteroid

I just tried adding the test column following your direction and..... wait for it.......

 

IT WORKED.....

ACE Emeritus
ACE Emeritus

Are you saying you want the same column in each of the 3 outputs and some o fthe outputs will say "yes" while the others say "no"? 

 

If so you would simply have 3 formula tools, with each output attached to a formula tool.  Then you would create your new field and put your logic in....

 

If you are saying something else I am sadly not following, so could you simply provide a sample of your data in Excel along with the output you want and I can get it working for you :-)

 

Thank you Rod for explaining the generate rows tool as I have never used it before!

Asteroid

Everyone thanks for the help.  I am going to try all different formulas for this to see what works but atleast I know that I need to use the Formula tool and not the 'Generate Row' tool. 

 

Will keep you posted on this.....

Labels