I have a case where I need to assign automatic or manual users based on 'Change Route' and the following activities that occurs simultaneously at the same time as 'Change in Delivery Date' and 'Change Confirmed Quantity'. But the logic that I'm using doesn't seem to be working. See code below:
CASE
WHEN
"_CEL_MERGED_ACTIVITIES"."ACTIVITY" IN ('Change Route')
AND
PU_FIRST(
"VBAP",
"_CEL_MERGED_ACTIVITIES"."TIMESTAMP",
"_CEL_MERGED_ACTIVITIES"."ACTIVITY" IN ('Change Confirmed Quantity')
)
=
PU_LAST(
"VBAP",
"_CEL_MERGED_ACTIVITIES"."TIMESTAMP",
"_CEL_MERGED_ACTIVITIES"."ACTIVITY" IN ('Change Route')
)
THEN
'Manual'
WHEN
"_CEL_MERGED_ACTIVITIES"."ACTIVITY" IN ('Change Confirmed Quantity')
AND
PU_FIRST(
"VBAP",
"_CEL_MERGED_ACTIVITIES"."TIMESTAMP",
"_CEL_MERGED_ACTIVITIES"."ACTIVITY" IN ('Change Confirmed Quantity')
)
=
PU_LAST(
"VBAP",
"_CEL_MERGED_ACTIVITIES"."TIMESTAMP",
"_CEL_MERGED_ACTIVITIES"."ACTIVITY" IN ('Change Route')
)
THEN
'Automatic'
END