Alteryx Designer Desktop Discussions

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

DateTimeDiff Formula Not Working

MattR79
8 - Asteroid

I am trying to calculate the amount of days between the current date and then determine whether something is out of SLA based on the amount of days difference.  The issue that I am running into is that since I essentially want to exclude weekends then if the current day is Monday or Tuesday the line should be included if the age is >5 and otherwise the line should be included if the age is >2.  Below is the formula I am using and even though today, the day I am writing this, is Tuesday the line is included despite the age being 3.  Any idea on why the formula is not working.  See the formula and the item that is being included in error.

 

Formula:

if
IsEmpty([Comments]) and
datetimeformat(DateTimeToday(), "%A") = "MONDAY"
and [Age] > 5
then "Y"
elseif
(IsEmpty([Comments])
and
(DateTimeFormat(DateTimeToday(), "%A") = "TUESDAY")
and [Age] > 5)
then "Y"
elseif
IsEmpty([Comments]) and [Age] > 2
then "Y"
else
"N"
endif

 

CommentsAge
 3
4 REPLIES 4
binuacs
21 - Polaris

@MattR79 try the formula 

 

If IsEmpty(Trim([Comments])) and [Age] > 5 and
   (DateTimeFormat(DateTimeToday(), "%A") = "MONDAY" or DateTimeFormat(DateTimeToday(), "%A") = "TUESDAY") 
then 
   "Y"
elseif 
   IsEmpty(Trim([Comments])) and [Age] > 2 
then 
   "Y"
else 
   "N"
endif

 

MattR79
8 - Asteroid

Unfortunately that is still not working, I am still showing that one record as being out of SLA despite it being Tuesday and the aging only being 3 days.  I think the issue is that the record meets the requirements for the comments being empty and the aging being >2.  I need a way to exclude those from being captured in that portion of the formula.

binuacs
21 - Polaris

@MattR79 can you provide a sample input file and expected output result? I tried with the below input and gave the result 

image.png

MattR79
8 - Asteroid

See below for some rows of sample data as well as what I would expect to be returned based on a Monday or Tuesday.  Based on what you provided in the image below you are having the same issue as I am.  On the record where the age is 3 I would expect that to have a no as the result due to today being Tues.  I was able to solve the problem by adding another section in the formula where I called out the remaining days of the week specifically, however, I have a few other tools using the same or similar formulas and I'm hoping to not have to do that for all of them.

 

Input

ClientCommentAgeExpected Result
Company A 3N
Company B 5Y
Company CSample Comment12N

 

New Formula:

 

If
(IsEmpty([Comments]) and [Age] > 4 and (DateTimeFormat(DateTimeToday(), "%A") = "MONDAY" or DateTimeFormat(DateTimeToday(), "%A") = "TUESDAY")) then "Y"
elseif
(IsEmpty([Comments]) and [Age] > 2 and (DateTimeFormat(DateTimeToday(), "%A") = "WEDNESDAY" or DateTimeFormat(DateTimeToday(), "%A") = "THURSDAY" or DateTimeFormat(DateTimeToday(), "%A") = "FRIDAY" or DateTimeFormat(DateTimeToday(), "%A") = "SATURDAY" or DateTimeFormat(DateTimeToday(), "%A") = "SUNDAY")) then "Y"
else
"N" endif

Labels
Top Solution Authors