Happy 8th birthday to the Maveryx Community! Take a walk down memory lane in our birthday blog, and don't miss out on the awesome birthday present that all Maveryx Community members get to take advantage of!

Alteryx Designer Desktop Discussions

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

Converting a v_string to a number in an IF, THEN, Else Statement

6 - Meteoroid

What's the proper syntax for this statement......IF [Quarter] = "Q1" THEN ToNumber[% of FY]* [PYABA] ELSE " " ENDIF


Te [% of FY] field is a v_string data type....

Alteryx Alumni (Retired)

I would just change the Else.  Since this is set up to be a number based on what I see, but the Else would be a string.  Also missing the () around the tonumber()


Options (changes in bold):

Make it a string

IF [Quarter] = "Q1" THEN tostring(ToNumber([% of FY])* [PYABA]) ELSE " " ENDIF


As a number

IF [Quarter] = "Q1" THEN ToNumber([% of FY])* [PYABA] ELSE 0 ENDIF

or if you don't want zeros you can use nulls

IF [Quarter] = "Q1" THEN ToNumber([% of FY])* [PYABA] ELSE null() ENDIF  


The final option is to just change the [% of FY] to a number with the Select tool before the Formula.


Hope this helps.


Scott Jones
Strategic Sales Engineer
Alteryx, Inc.