We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Writing Conditional Statements

bsolove
8 - Asteroid

I have a data set of apportionment percentages.  The data type is double.  There are a few negative percentages that I want to replace with zeros.  I tried IF [Apportionment %] < 0 THEN "0" ELSE [Apportionment %] ENDIF, but I get an error message that says the formula "Apportionment %" resulted in a string but the field is numeric.  Use ToNumber(...) if this is correct.  The field "" is not contained in the record.  What am I doing wrong here??  New to Alteryx, so please keep that in mind :)

 

 

7 REPLIES 7
MarqueeCrew
20 - Arcturus
20 - Arcturus
"0" is a string. Please try:

IF [Apportionment %] < 0 THEN 0 ELSE [Apportionment %] ENDIF

Another fine choice is:

Max(0,[Apportionment %])

Cheers,
mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
bbak
9 - Comet

You need to take the 0 out of the quotes. By putting it in quotes you are saying that you would like to return a string. Removing the quotes should do the trick!

bsolove
8 - Asteroid

If I remove the quotes, the error says the field "" is not contained in the record.  I get the same error if I use the Max formula above.

 

 

bbak
9 - Comet

Ah, that is because you need to choose the Apportionment % column in the "Select Column" drop down in the formula tool. If you don't pick the column then Alteryx doesn't know what data it is modifying.

 

Solution.PNG

bsolove
8 - Asteroid

I already had that chosen as well.  

 

I still get the message "the field "" is not contained in the record (Expression #2)."

bbak
9 - Comet

That means that you have another formula down below that doesn't have the output column selected.

 

Capture.PNG

bsolove
8 - Asteroid

That worked.  Thank you!

Labels
Top Solution Authors