In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Converting V_WString to Double

MikiA
6 - Meteoroid

Appreciate any tips to solve this issue - I converted a V_Wstring (e.g., 123,456,777) into Double, that is, from string to numeric, but the output turned out to be missing data (e.g., 123). Wonder if I should choose another data type in the SELECT tool? 

 

 

9 REPLIES 9
MinhLO
8 - Asteroid

Hi @MikiA ,

You can use the ToNumber function, and output your field as double.

Attached a solution.

If you have multiple fields, you can use the multi-field formula:

 

MinhLO_0-1762520946501.png

 

MikiA
6 - Meteoroid

thanks a lot - wonder if there's a single workflow to achieve the same outcome 

MinhLO
8 - Asteroid

Sorry what do you mean with 'a single workflow'?

MikiA
6 - Meteoroid

You solution involves two steps - (1) ToNumber formula and (2) Select tool (converting string to Double). 

 

Just curious if I can do it in one single step (assuming the select tool should allow me to convert string to numeric)

MinhLO
8 - Asteroid

2 different possibilities: 

- on the higher branch with the multifield formula which allows you to select multiple fields => 1 tool

- lower branch with a formula tool if you only have one field to cast. => you are right, you need a select after

 

With the multifield formula you can configure as follow:

MinhLO_0-1762522570109.png

Hence the result will be cast in double.

Data:

MinhLO_1-1762522602794.png

 

 

 

 

jrlindem
12 - Quasar

@MikiA  You are correct in that you should be able to just use the Select Tool to do this.  At times, it may be necessary to use the Formula or Multi-Field Formula Tools as @MinhLO pointed out to accomplish this, so having all of those techniques is good to have in your skillset.

 

Here's a quick illustration of the Select Tool, with some extra things to help show what's going on, but the basis is just the Select Tool.  The formula tool here is just to ensure the value is VSTRING going into the Select Tool, so ignore that for your workflow.  The Field Info Tools are just to validate the Field Type behavior, so you can ignore those pieces too for your workflow:

 

jrlindem_1-1762524329861.png

 

 

MinhLO
8 - Asteroid

Hey @jrlindem,

 

Thanks for stepping in!

Maybe I missed something, but from what I understood @MikiA  issue is related to his data in this format : 123,451. (coming in as a string)

Hence if you only use a select tool, as he did, it cast but truncates your value:

MinhLO_0-1762524759996.png

 

  Which is why the formula ToNumber([X]) seems necessary to me, and the multi field formula does it + proper casting post formula application. What do you think ? 

jrlindem
12 - Quasar

@MinhLO haha, yep, you're absolutely right!  I missed the comma's in my Input example.  Thanks for pointing that out.  So if there are not additional characters that force the behavior to act as a string then you can use Select, but since there are comma's, to your point, you would need to use Formulas to tailer it or a Cleanse to strip off the special characters ahead of the Select Tool.

 

Thanks!  -Jay

MikiA
6 - Meteoroid

thanks - that's what I am looking for if SELECT tool cannot work in this use case. 

Labels
Top Solution Authors