Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Malformed if Statement - DateTime

Greg2186
6 - Meteoroid

I'm attempting to derive an SLA Date Time in my data set ultimately for a datediff calculation, but I'm running into issues with my IF statement. What I'm trying to do is assign a different benchmark per group. My thought is to use the calculation below to create a string and then use the DATETIME tool to convert it back into the DATETIME format. Seems pretty simple, but I've been working on this for a few hours now and I can't seem to make it work.

 

IF [Group] = "GROUP 1"
THEN [RUN_DATE] +"15:00"
ELSEIF [Group] = "GROUP 2"
THEN [RUN_DATE] + "16:00"
ELSEIF [Group] = "GROUP 3"
THEN [RUN_DATE] + "17:00"
ELSE [Group] = "GROUP 4"
THEN [RUN_DATE] + "18:00"
ENDIF

 

I'm open to all suggestions, if there's a better way to attack this please let me know, as I'm pretty new to Alteryx.

2 REPLIES 2
patrick_digan
17 - Castor
17 - Castor

Your line "ELSE [Group] = "GROUP 4"" should just be an else statement and the THEN on the next line isn't needed:

IF [Group] = "GROUP 1"
THEN [RUN_DATE] +"15:00"
ELSEIF [Group] = "GROUP 2"
THEN [RUN_DATE] + "16:00"
ELSEIF [Group] = "GROUP 3"
THEN [RUN_DATE] + "17:00"
ELSE [RUN_DATE] + "18:00"
ENDIF

 try looking at the switch statement as an alternate to the if then else.

 

Greg2186
6 - Meteoroid

This solved it. Thanks!

Labels