Alteryx Designer Desktop Discussions

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

multi-condition formula not working

aberthiaume
7 - Meteor

I have a multi-condition formula that has always worked previously and is no longer working.  I am not sure why?  It seems fine until I try to close the formula with an "end" or "endif".  

 

 

If [Hospital Beds] <= 25 then '1-25 beds' elseif [Hospital Beds] >= 26 and [Hospital Beds] <= 99 then '26-99 beds' elseif [Hospital Beds]>= 100 and [Hospital Beds]<= 299 then '100-299 beds' elseif [Hospital Beds]>=300 then '300+ beds' else ' ' endif

 

 

aberthiaume_0-1629486608650.png

 

4 REPLIES 4
VictorLeonis
7 - Meteor

@aberthiaume  The error is happening before a run or in runtime?

I tried creating the same situation on my machine and it worked.

VictorLeonis_0-1629487332900.png

 

Just, check the space after >= 300 and check if [Hospital Beds] is a numeric field.

aberthiaume
7 - Meteor

Thank you for your response.  The "Hospital Beds" Field is a V_W String.    This is the error and this is the error I also get within the workflow.  This error pops up regardless of run.  

 

aberthiaume_0-1629488501276.pngaberthiaume_1-1629488527801.png

 

VictorLeonis
7 - Meteor

@aberthiaume  You can try using the function to ToNumber to convert String to the number and then be able to compare using operators >. >=,

 

If ToNumber([Hospital Beds]) <= 25 then '1-25 beds' elseif ToNumber([Hospital Beds]) >= 26 and ToNumber([Hospital Beds]) <= 99 then '26-99 beds' elseif ToNumber([Hospital Beds]) >= 100 and ToNumber([Hospital Beds]) <= 299 then '100-299 beds' elseif ToNumber([Hospital Beds]) >= 300 then '300+ beds' else ' ' endif

 

VictorLeonis_0-1629488991933.png


Or you can try to use a select tool before the formula and change the datatype. 

aberthiaume
7 - Meteor

That makes sense.  I will try that! Thank you! 

 

Labels