Getting a "Malformed If Statement" error when using the following formula. I am trying to filter on dates 0-39 days to say "Yes", else "No". The date of the field I am using to filter is MM-dd-yyyy.
if(ABS(DateTimeDiff(DateTimeNow(),[Last Discovered],"days"))) <=39 THEN "Yes" ELSE "NO"
Any ideas why there is an error?
Solved! Go to Solution.
Hi,
drop the ( at the beggining and add an endif - this should work:
if ABS(DateTimeDiff(DateTimeNow(),[Last Discovered],"days"))<=39 then "Yes" else "No" endif
Hi @seanjon13,
I think you got some brackets () wrong and missed the ENDIF, but that's it. Try this one:
if ABS(DateTimeDiff(DateTimeNow(),[Last Discovered],"days")) <=39
THEN "Yes"
ELSE "NO"
ENDIF
Best
Alex
Hi!
As a leader in the Alteryx Community, I have the ability to identify & mark accepted solutions on behalf of community members - and recently did so on this thread. If you have any questions or concerns with the solution(s) I selected please let me know by replying to this post.
I've accepted the post by @zajaccount as the solution.
Though the posts above give you a valid working syntax, the true error in this isn't actually related to brackets, it's related to two issues;
1) you have no ENDIF at the end of your statement (which is pointed out above)
2) with an IF, it must be followed by a space before any further syntax (not covered by the above)
To summerize the statement...
if (ABS(DateTimeDiff(DateTimeNow(),[Last Discovered],"days"))) <=39 THEN "Yes" ELSE "NO" endif
will work, but I do believe they are right to suggest moving the brackets from around the ABS too as these are unnecessary.
Learn more about Accepted Solutions here.
Thank you!