Hi,
I am started to use alteryx and I am dealing with an issue.
I would like to use a dynamic fields selections bases on a list of columns. I know it's possible to use a dynamic selection, and specify name or field number but I want to specify a list of multiple fields.
I don't know if there something to do this, like a looping or macro.
For example there is my data :
ID | Personal | Cars | School | City | Father_relationship | Mother_relationship | Sister_relationship | Brother_relationship | Job |
ID 1 | Person 1 | Cars 1 | School 1 | City 1 | Father 1 | Mother 1 | Sister 1 | Brother 1 | Job 1 |
ID 2 | Person 2 | Cars 2 | School 2 | City 2 | Father 2 | Mother 2 | Sister 2 | Brother 2 | Job 2 |
ID 3 | Person 3 | Cars 3 | School 3 | City 3 | Father 3 | Mother 3 | Sister 3 | Brother 3 | Job 3 |
ID 4 | Person 4 | Cars 4 | School 4 | City 4 | Father 4 | Mother 4 | Sister 4 | Brother 4 | Job 4 |
ID 5 | Person 5 | Cars 5 | School 5 | City 5 | Father 5 | Mother 5 | Sister 5 | Brother 5 | Job 5 |
ID 6 | Person 6 | Cars 6 | School 6 | City 6 | Father 6 | Mother 6 | Sister 6 | Brother 6 | Job 6 |
ID 7 | Person 7 | Cars 7 | School 7 | City 7 | Father 7 | Mother 7 | Sister 7 | Brother 7 | Job 7 |
ID 8 | Person 8 | Cars 8 | School 8 | City 8 | Father 8 | Mother 8 | Sister 8 | Brother 8 | Job 8 |
ID 9 | Person 9 | Cars 9 | School 9 | City 9 | Father 9 | Mother 9 | Sister 9 | Brother 9 | Job 9 |
ID 10 | Person 10 | Cars 10 | School 10 | City 10 | Father 10 | Mother 10 | Sister 10 | Brother 10 | Job 10 |
ID 11 | Person 11 | Cars 11 | School 11 | City 11 | Father 11 | Mother 11 | Sister 11 | Brother 11 | Job 11 |
ID 12 | Person 12 | Cars 12 | School 12 | City 12 | Father 12 | Mother 12 | Sister 12 | Brother 12 | Job 12 |
ID 13 | Person 13 | Cars 13 | School 13 | City 13 | Father 13 | Mother 13 | Sister 13 | Brother 13 | Job 13 |
ID 14 | Person 14 | Cars 14 | School 14 | City 14 | Father 14 | Mother 14 | Sister 14 | Brother 14 | Job 14 |
ID 15 | Person 15 | Cars 15 | School 15 | City 15 | Father 15 | Mother 15 | Sister 15 | Brother 15 | Job 15 |
ID 16 | Person 16 | Cars 16 | School 16 | City 16 | Father 16 | Mother 16 | Sister 16 | Brother 16 | Job 16 |
ID 17 | Person 17 | Cars 17 | School 17 | City 17 | Father 17 | Mother 17 | Sister 17 | Brother 17 | Job 17 |
ID 18 | Person 18 | Cars 18 | School 18 | City 18 | Father 18 | Mother 18 | Sister 18 | Brother 18 | Job 18 |
ID 19 | Person 19 | Cars 19 | School 19 | City 19 | Father 19 | Mother 19 | Sister 19 | Brother 19 | Job 19 |
And my list of fields :
Fields |
ID |
Personal |
School |
Sister_relationship |
Job |
So I would like to keep, only this fields in my data.
i gave you a little example, but imagine I have thousand of fields, I can't use a formula base on a name (name="Id" or Name="Personal"....) nor even using the fieldnumber.
I can't not also transpose my columns from the data into rows and join both, because i will have millions of rows.
So i am looking for a solution which will not necessarily change the data structure.
Thank you for your help.
Hi @Vanderleck16 ,
You can find an answer to your question in this thread :
The only difference is that you don't want to exclude the fields that come from your list of fields, rather include them. A small tweak was necessary in the batch macro, to set the dynamic select tool expression from NOT IN to IN.
In your instance, this will be the workflow you are after
Hope that helps, let me know if you have any questions.
Cheers,
Angelos
That is amazing @PhilipMannering 🤯
Thanks @AngelosPachis. 🙂 Came up with it myself. I can't believe it's not more straightforward to select fields based on a list, but this is a good start.
@PhilipMannering
Thank you so much, It is very helpful. You're solution is easy to use.
I have a question that comes to my mind, for example, if in my list there is a field that is not in the database, what happens for this field, is it still added in description ?
Thank you again for the solution that works wonderfully.