ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Creating dummy variables

rajeshmr06
Átomo

How can I easily create dummy variables for a given Field?

 

For example, let's say a Field Category has the unique values of x,y and z. I want to create dummy_x, dummy_y and dummy_z with values of 1 or 0 based on the Category field. Now, I have more than 3 unique values and it is difficult to create the dummy variables one by one. 

 

Is there a way to dynamically create the dummy variables based on the values of a particular field?

8 RESPUESTAS 8
Rohit_Bajaj
Cometa
Hi Rajesh, Can you please some tabular example what is the as-is/source and what the output would look like? Thanks, Rohit
jdunkerley79
ACE Emeritus
ACE Emeritus

Yes you can create dummy for each.

 

The easiest way I can think of is to use a transpose to put all the fields you want to create as rows.

You can then use a formula tool to make a dummy column name.

Then use a cross tab to make it column based.

After this you can use a MultiField formula tool to fill in the nulls.

2016-10-06_09-30-10.jpg

Sample attached

 

 

rajeshmr06
Átomo

Thanks, that worked well.

 

CrossTab with the boolean Field added is what I was looking for. 

p_g
Átomo

Hi, please could you share what the workflow looks like for the crosstab + boolean field you mentioned?

p_g
Átomo

Ignore, it is in 

SanK
Átomo

Similar to Nebula's method but slightly straight forward.

Make Dummys_SK.PNG

vannam68
Átomo

Thank you for your solution

MarqueeCrew
20 - Arcturus
20 - Arcturus

 Please also try our new macros from CReW

 

https://gallery.alteryx.com/#!app/CReW-Generate-Dummy-Variables/5fca958e0462d71998cd0aac 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Etiquetas
Autores con mayor cantidad de soluciones