[Data Type] vs [Data Type] : Forced
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
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...
Solved! Go to Solution.
- Labels:
- Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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:
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.
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.
I'm attaching my sample in case you wanted to test it out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks @patrick_digan that was extensive reply. From your answer, do I takeaway that forcing a data type works only in macros?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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:
For a normal select tool, notice how the xml isn't even storing the field names or datatypes:
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:
Now alteryx will take field1 and regardless of the datatype it comes in as, it will leave the select tool as type double.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you @patrick_digan that is comprehensive, appreciate it.
![](/skins/images/4AD62B665AB5C9F49FE7F2C9A79805ED/responsive_peak/images/icon_anonymous_message.png)