Free Trial

Alteryx Designer Desktop Discussions

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

need some help in converting the if condition...

Raj_007
8 - Asteroid

Hi All,

I have this IF condition which is from another tool.. i need to convert this into Alteryx IF condition

 

If([DR2 - Last Valid Date]< [SR1 - Last Valid Date] and [SR1 - Test Passed] = 'Yes' ,  - This is the condition

 

[SR1 - Last Valid Date] +365 ,  --This is the THEN part

 

--This is the ELSE Part

If([DR2 - Test Passed] = 'Yes',

        [DR2 - Last Valid Date]+365 ,

 'No Test Date')

)

 

 

 

6 REPLIES 6
pedrodrfaria
13 - Pulsar

Hi @Raj_007 

 

This is how you would write this in Alteryx. I'm assuming that the columns with the name Date contain date information. 

 

IF [DR2 - Last Valid Date] < [SR1 - Last Valid Date] and [SR1 - Test Passed] = 'Yes'

THEN datetimeadd([SR1 - Last Valid Date],365, 'days')

ELSEIF [DR2 - Test Passed] = 'Yes'

THEN datetimeadd([DR2 - Last Valid Date], 365,'days')

ELSE 'No Test Date'

ENDIF

 

I attached a workflow for educational purposes.

pedrodrfaria_0-1614825893583.png

 

 

 

Pedro.

fmvizcaino
17 - Castor
17 - Castor

Hi @Raj_007 ,

 

Alteryx doesn't understand the sum of dates + numbers as in here ([SR1 - Last Valid Date] +365), that is why you need to use a specific function to achieve what you are looking for, exactly as @pedrodrfaria wrote.

 

To learn more about conditional statements and dates, check the following links.

 

https://community.alteryx.com/t5/Interactive-Lessons/Writing-Conditional-Statements/ta-p/98910

https://help.alteryx.com/current/designer/datetime-functions

 

Best,

Fernando Vizcaino

Qiu
21 - Polaris
21 - Polaris

@Raj_007 
As @pedrodrfaria explained, we need to be careful abou the data type.

And I think it is better to do some Data Cleansing first based on your real business workflow.

CaptureF1A.PNG

Raj_007
8 - Asteroid

Hi Pedrodrfaria, fmvizcaino, Qiu - Thank you so much for your input, really appreciate your time

Unfortunately, those columns are not DATE datatype they are strings as they have Gap, N/A in it.

Does this mean i cannot check if Date1 < Date2 within the string using the DateFormat and DateParse... iam almost there

while testing this is what i noticed.. the < is not getting worked 

 

IF [Band Temp] ='1' AND [DR2 - Last Valid Date] NOT IN ('Gap','N/A') AND [SR1 - Last Valid Date] NOT IN ('Gap','N/A')
AND DateTimeFormat(DateTimeParse([DR2 - Last Valid Date],'%m/%d/%Y'),'%m/%d/%Y') < DateTimeFormat(DateTimeParse([SR1 - Last Valid Date],'%m/%d/%Y'),'%m/%d/%Y')
THEN '1'
Else 'No Test Date'
ENDIF

 

In the output column all i see is No Test Date - when i worked on each one by one i found that the hilighted in color is not working

how do i approach this way

 

Raj_007
8 - Asteroid

 DateTimeFormat(DateTimeParse([DR2 - Last Valid Date],'%m/%d/%Y'),'%m/%d/%Y') < DateTimeFormat(DateTimeParse([SR1 - Last Valid Date],'%m/%d/%Y'),'%m/%d/%Y')

 

when i took out the DateTimeFormat  from the above line - the condition is getting checked - for some reason DateTimeFormat is not working in the above with the < check - please suggest any reason

Raj_007
8 - Asteroid

Figured out - DateTimeFormat() - This function is only used to convert the DATE data type field into string .. so when i used with date parse i am trying to compare the 2 strings thats why its not working - thanks a lot

Labels
Top Solution Authors