String value for a numeric field
- 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 everyone,
I'm struggling with trying to write a "N/A" string for a numeric field.
To be more specific, my formula tool needs to calculate the difference between two fields (so the field type should be numeric), but in case one of them is blank, I would like Alteryx to mark the record as "N/A".
While trying to do this, you receive the following error message: The formula [Formula Name] resulted in a string but the field is numeric. Use ToNumber (...) if this is correct.
Formula used so far:
IF !IsNull([Numeric variable #1]) THEN ToNumber([Numeric value #1]-[Numeric value #2]) ELSE "N/A" ENDIF
Are you aware of any alternative solutions to achieve this?
Thanks in advance!
D.
- Labels:
- Dynamic Processing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
"n/a" is a string - null() is numeric any type of missing data.
you can have the null() converted to a display value ie ("n/a") in a table tool, but you can't have that value in a numeric field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for your prompt reply!
So there is no way to have "N/A" written in the field in the output file in excel instead of having it empty? If so, how can I achieve it? I am asking this, because the "Null ()" formula ends up producing an empty record.
D.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @dbuz , as @apathetichell mentioned your field will need to either be a numeric field showing the result of the calculation, or a string if you want to show "N/A". You could convert your numeric result to a string, and output everything as a string, but Excel will show the message 'The number in this cell is formatted as text or preceded by an apostrophe'. Would outputting two columns be an option? Output a "N/A" beside in the string field beside the numeric field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@dbuzas @markcurry mentioned you can either convert to string using a multi-field formula with all of your numeric fields selected and the formula of:
if isempty([_currentfield_] then "N/A" else tostring([_currentfield_]) endif
before ending as your last tool before output...
There's a way to do it in TABLE which "should" allow you to keep your output as numbers in excel. see the screenshot attached.
 
