Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

List box to change data type for multiple fields in Analytic App?

indicksean
6 - Meteoroid

Hello everyone,

 

I'm trying to figure out if it's possible to have a user of my Analytic App select multiple fields from a list box and as a result the data types for those fields change to double. I know with a single drop down tool I can do this by having the action tool update the incoming field name and forcing the data type to double but I'm struggling to find a way if I want the user to select multiple fields.

 

We have users that may not know their data when selecting a file to run through the App. They know which columns should be numeric so I'm trying to get the List Box to display all of the fields that are coming through as Text and then the user can select those which should be changed to double and have the App update the field types just for those fields selected. 

 

Any help would be appreciated.

 

Thanks

4 REPLIES 4
mceleavey
17 - Castor
17 - Castor

Hi @indicksean ,

 

This can be achieved in the same method but using a list box rather than a dropdown. The List box allows you to select multiple values. You may need to then use a macro to cycle throught eh selections.

 

M.



Bulien

indicksean
6 - Meteoroid

Hi @mceleavey 

 

Got it. So essentially using the list box to first make selections and then feeding each selection through a macro to change the data type. 

 

As an example using that method I'll have Field A (Date), Field B (String), Field C (String), Field D (Bool) and the user selects Field B and Field C in the list box. That will feed Field B and C through a macro to change the field types to double. Since I don't want to lose Field A or Field D what is the easiest way to combine Field A and Field D with the new Field B (Double) and Field C (Double) while removing Field B (String) and Field C (String)?

 

Thanks!

danilang
19 - Altair
19 - Altair

Hi there @indicksean 

 

Here's a non-macro solution.  

 

WF.png

The first Select just ensures that all the fields are strings, since the text box assigns numeric data types when it can.  After this, the List box input kicks in and displays all the fields. The action tool is configured to "Update Select with multi-select List box"  which automatically changes the selection in the Select to match the List box.  The Field Info tool gets the select field names and the next Formula tool prepends "New_" to the name.  The list of new field names is fed to the Dynamic rename which changes the names of the selected from the original data.  The top branch after this Selects the fields that start with "New_", changes their type to double and then removes the "New_".  The bottom branch selects the fields that weren't picked by the user.  The join matches up the new and unchanged columns on record position, to give you the original data with the user selected fields changed to Double.

 

Here's the output of the Browse that's connected to the last Field Info tool, showing that type of column C, the one I selected in the UI, was changed to double, as well as the data

 

Field Types.pngData.png

 

The only issue now is that the fields are out of order, but that's a problem for another day

 

Note: the attachment is an Alteryx package, since the Community web site doesn't allow you to attach Apps directly.  Just drag it on to your canvas, and the app will be extracted

 

Dan

indicksean
6 - Meteoroid

@danilang - really appreciate this. This was the route I started to envision in trying to find a non-macro solution and this ties it all together. And yes, unfortunately even with the Field Sort macro there doesn't appear to be an easy solution to re-order fields to the previous order as the field types default back to string when you create a sorting mechanism for the field names along with a dynamic rename and union. But that is something easy to live with.

 

Thanks again!

Labels