Alteryx Designer Desktop Discussions

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

[Data Type] vs [Data Type] : Forced

AmrSHOULA
7 - Meteor

Hello Alteryx Community,

 

I am trying to figure out the difference between a data type vs a forced data type.

Looking in the online documentation of the Select Tool I found this hint:

 

Use the [data type]: Forced option to ensure a column always contains the expected data type; this is helpful when creating macros.

 

I tried to simulate this effect by the below workflow:

ForcedDataType.jpg

But as you see, although I forced the Data Type of Col1 to Double in the first Select, the second Select was able to change it to Byte. Did I misunderstood the hint from the documentation? Is this not the right utilization of the forced data type?

 

Appreciate if somebody can help or guide

 

Thanks in advance...

6 REPLIES 6
patrick_digan
17 - Castor
17 - Castor

@AmrSHOULA Great question. Here's an example. Suppose my simple macro adds .01 to the field you select. I typed in 5.0 in the macro input which makes it a double. Here is my macro with the select, where it shows as a double:

patrick_digan_0-1596737955907.png

 

Now suppose my workflow has data of type byte (or integer for that matter). My macro will also have that data type, for better or worse. In this case it doesn't work, because byte and integer wouldn't work for 5+.01. 

 

patrick_digan_2-1596738299042.png

 

 

 

To fix this, you can use the double:forced option in the macro. This means that even if it's a byte or integer coming into the select tool, it will be converted to a double, which will then allow my formula tool to process correctly.

patrick_digan_3-1596738363452.png

I'm attaching my sample in case you wanted to test it out!

 

CharlieS
17 - Castor
17 - Castor

I've found Select tools (even the "Forced" options) to be weak in application. When I need to force a data type conversion, I use the Multi Field Formula tool. It allows you to change the field type and apply any custom expression that may be necessary to facilitate that process (especially powerful with RegEx). 

AmrSHOULA
7 - Meteor

Thanks @patrick_digan that was extensive reply. From your answer, do I takeaway that forcing a data type works only in macros?

AmrSHOULA
7 - Meteor

Thanks @CharlieS  for answering my question.

I understand that Formula tool(s) can modify added columns' data types, but I am referring to Forced data type option in Select tool as well as being embedded in the Join tool.So let me ask you this, by "weak" do you mean have no effect? If that is the case, could that be a bug?

patrick_digan
17 - Castor
17 - Castor

@AmrSHOULA Forcing a data type would work in any situation, but macros are the best example/use case. 

 

In case you're interested, looking at the xml behind the select tool may also give you a better understanding of how alteryx thinks.You'll have to make sure your user settings to display xml are checked:

patrick_digan_0-1596801800143.png

For a normal select tool, notice how the xml isn't even storing the field names or datatypes:

patrick_digan_1-1596801839772.png

So the select tool is just a pass through if no changes are made. Whatever field/datatypes come into the tool, they leave as the same. If you want to ensure that something is type double (and your sample data is also type double), then you can force it:

patrick_digan_2-1596801933584.png

Now alteryx will take field1 and regardless of the datatype it comes in as, it will leave the select tool as type double.

 

AmrSHOULA
7 - Meteor

Thank you @patrick_digan that is comprehensive, appreciate it.

Labels