Start Free Trial

Alteryx Designer Desktop Discussions

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

IF THEN statement with string and numeric values

emarsha1
5 - Atom

Hi Everyone!

 

I'm fairly new to Alteryx and am having trouble with an IF THEN statement.

 

I have the following and am getting a malformed statement error:

 

if [AdmitAMPM]="AM" then [AdmitTime]
elseif [AdmitAMPM]="PM" then [AdmitTime]+12
else 0
endif

 

AdmitAMPM is vstring and AdmitTime is double

My new variable will be AdmitHour and I have it listed as Double

 

Any help would be much appreciated!

7 REPLIES 7
ImadZidan
12 - Quasar

Hello @emarsha1 ,

 

Which tool are you getting this in. It is not the formula? just tested it and its ok.

 

Can you please provide a screen shot of where you are issuing this statement.

EricaR
Alteryx Alumni (Retired)

Would it be possible to share your workflow? Just a few rows with those fields.  I don't immediately see an issue with the syntax, but I'm wondering about the [AdmitTime] field.  Is something like 1200, 1300, etc?  

emarsha1
5 - Atom

I'm using the formula tool

 

Formula tool Capture.JPG

emarsha1
5 - Atom

Data Capture.JPG

Admit time is essentially the hour from the AdmitDate field

ImadZidan
12 - Quasar

Hello @emarsha1 ,

 

It looks to me that Admittime is not suitable for addition operation.

 

Please check it and make sure it is so. I can see the red underneath it.

 

Just a bit of test, take out the 12 and see if doesn't complain anymore. 

ImadZidan
12 - Quasar

Hello @emarsha1 ,

 

I see what's happening, It may well be the null values.

Can you  replace nulls with 0 using the datacleansing tool on that field or all of them.

 

 

emarsha1
5 - Atom

That worked! Just needed to change AdmitTime to double.

 

Thank you!!!

Labels
Top Solution Authors