Hi Alteryx community, I am trying the rule below but it is replacing some statuses that should not be replaced. The first part of the formula is working but the second part, after the ELSEIF statement, is replacing some statuses for "should be Contracted by now". Could someone please let me know what is wrong?
IF DATETIMEPARSE([End_date], "%Y-%m-%d") <= DATETIMEADD(DATETIMENOW(), -60, "days") AND !CONTAINS([Planning Status], "Actual spend confirmed") THEN "should be Actual spend confirmed by now" ELSEIF DATETIMEPARSE([Start_date], "%Y-%m-%d") <= DATETIMEADD(DATETIMENOW(), +14, "days") AND !CONTAINS([Planning Status], "should be Actual spend confirmed by now") OR !CONTAINS([Planning Status], "Contracted") THEN "should be Contracted by now" ELSE [Planning Status] ENDIF
INPUT
OUTPUT OF THE RULE THAT DOES NOT WORK PROPERLY
I think your issue is with your AND/OR logic here. You are saying if the date is less than or equal to 14 days from today and doesn't contain the first phrase OR doesn't contain the second phrase. I'm not sure exactly what logic you are looking to go for, but it seems like all of these rows you have mentioned don't contain one or the other which would make them valid. Also, you don't need a plus sign before the 14 days.
As far as I can tell, your formula is doing exactly what you have asked it to. Assuming the date is less than or equal to 14 days from today and it doesn't contain one of the two phrases it will be set as "should be Contracted by now". What is your reasoning that some of them are being set incorrectly?
Thank you. I tweaked the formula and it worked.
IF DATETIMEPARSE([End_date], "%Y-%m-%d") <= DATETIMEADD(DATETIMENOW(), -60, "days") AND !CONTAINS([Planning Status], "Actual spend confirmed") THEN "Should be Actual spend confirmed by now" ELSEIF CONTAINS([Planning Status], "Budget approved") OR CONTAINS([Planning Status], "Budget approver") OR CONTAINS([Planning Status], "Lead Planner") OR CONTAINS ([Planning Status], "should be") AND DATETIMEPARSE([Start_date], "%Y-%m-%d") <= DATETIMEADD(DATETIMENOW(), +14, "days") THEN "Should be Contracted by now" ELSE [Planning Status] ENDIF