Start Free Trial

Alteryx Designer Desktop Discussions

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

Fix Error Results resulted in a String but the Field is Numeric

KamenRider
11 - Bolide

Guys, please help me in correcting the formula. Below is the data 

 

Formula.JPG

I have this formula "Results = IF PRICE 1 = 0 THEN 0 ELSEIF

IS(NULL) ([PRICE1]) THEN "ERROR" ELSE PRICE1 - PRICE2 ENDIF

 

Pease advise how to fix this if Error is states "the formula in Price1 resulted to  string format. Use to number..."

 

Thanks,

Kamen

 

5 REPLIES 5
Peachyco
11 - Bolide

Your code is throwing a different error when I try it, likely because of incorrect syntax (e.g. "IS(NULL)" doesn't work).

 

Try the code below. It works for me when using your sample data:

Alteryx screenshot.png

Alteryx screenshot.png

KamenRider
11 - Bolide

HI @Peachyco 

 

Appreciate your response. What if the Results field data type is fixed decimal with 2 decimal points. Can you still produce the "error" condition. I would like to convert the result into 2 decimal points. If you any more ideas, please share.

 

Looking forward for your response.

 

thanks,

Kamen

ncrlelia
11 - Bolide

Hi @KamenRider,

 

You can convert [Price 1] into 2 decimal points using ToNumber function. That is, ToNumber([Price1]), then change the data type and size accordingly.

Hope this helps.

 

Cheers, 

Lelia

Peachyco
11 - Bolide

@KamenRider 

If you want the numeric outputs to take the template "0.00", then you can wrap the numeric outputs with the ToString ([Number], 2) function, like so (the second parameter "2" tells the function to keep two decimal places):

Alteryx screenshot.png

 

We can't assign FixedDecimal or any numeric type to the [Result] column if we want "ERROR" to be there as well - it has to be a string.

KamenRider
11 - Bolide

Hi @Peachyco 

 

Perfect!.. Thank you so much.

 

Kamen

Labels
Top Solution Authors