Alteryx Designer Desktop Discussions

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

Dynamic fields selection bases on a list of fields

Vanderleck16
7 - Meteor

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 :

 

 

IDPersonalCarsSchoolCityFather_relationshipMother_relationshipSister_relationshipBrother_relationshipJob
ID 1Person 1Cars 1School 1City 1Father 1Mother 1Sister 1Brother 1Job 1
ID 2Person 2Cars 2School 2City 2Father 2Mother 2Sister 2Brother 2Job 2
ID 3Person 3Cars 3School 3City 3Father 3Mother 3Sister 3Brother 3Job 3
ID 4Person 4Cars 4School 4City 4Father 4Mother 4Sister 4Brother 4Job 4
ID 5Person 5Cars 5School 5City 5Father 5Mother 5Sister 5Brother 5Job 5
ID 6Person 6Cars 6School 6City 6Father 6Mother 6Sister 6Brother 6Job 6
ID 7Person 7Cars 7School 7City 7Father 7Mother 7Sister 7Brother 7Job 7
ID 8Person 8Cars 8School 8City 8Father 8Mother 8Sister 8Brother 8Job 8
ID 9Person 9Cars 9School 9City 9Father 9Mother 9Sister 9Brother 9Job 9
ID 10Person 10Cars 10School 10City 10Father 10Mother 10Sister 10Brother 10Job 10
ID 11Person 11Cars 11School 11City 11Father 11Mother 11Sister 11Brother 11Job 11
ID 12Person 12Cars 12School 12City 12Father 12Mother 12Sister 12Brother 12Job 12
ID 13Person 13Cars 13School 13City 13Father 13Mother 13Sister 13Brother 13Job 13
ID 14Person 14Cars 14School 14City 14Father 14Mother 14Sister 14Brother 14Job 14
ID 15Person 15Cars 15School 15City 15Father 15Mother 15Sister 15Brother 15Job 15
ID 16Person 16Cars 16School 16City 16Father 16Mother 16Sister 16Brother 16Job 16
ID 17Person 17Cars 17School 17City 17Father 17Mother 17Sister 17Brother 17Job 17
ID 18Person 18Cars 18School 18City 18Father 18Mother 18Sister 18Brother 18Job 18
ID 19Person 19Cars 19School 19City 19Father 19Mother 19Sister 19Brother 19Job 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.

 

5 REPLIES 5
PhilipMannering
16 - Nebula
16 - Nebula

A lot of people will tell you to transpose your data and join Name to your list, but here's what I like to do,

Add the column name as a description -> select fields with a description. See attachment,

PhilipMannering_0-1614246449571.png

 

AngelosPachis
16 - Nebula

Hi @Vanderleck16 ,

 

You can find an answer to your question in this thread :

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Deselecting-columns-due-to-a-separate-...

 

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

 

AngelosPachis_0-1614246645214.png

 

Hope that helps, let me know if you have any questions.

 

Cheers,

 

Angelos

AngelosPachis
16 - Nebula

That is amazing @PhilipMannering  🤯

PhilipMannering
16 - Nebula
16 - Nebula

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.

Vanderleck16
7 - Meteor

@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.

 

 

Labels