Skip to main content
Question

PQL compare dates on activity level


Hi @janpeter.van.d​ / @Celopeers .​ 

 

I'm trying to compare two dates from different columns in order to find out about a delay.

 

For this I need to

(1) compare the highlighted dates in the red box

(2) if the ETA is earlier than the Timestamp of the Activity "Ready for Pickup" I need to mark it with the value "1" in the respective column and line (as highlighted)

 

[Note that the columns "ETA" and "Delay" are two manually created attributes within Celonis and were not part of the extracted data.]

 

I guess I need to use a PU function here, but as I'm not very familiar with it I'd very much appreciate any help.

 

Thanks in advance anf brgds, Finn

I actually have the same problem! :)


janpeter.van.d
Level 8
Forum|alt.badge.img+19

Hi @1461001156,

 

In the column Delay, you could put something like this:

 

CASE

WHEN

-- get the difference of two timestamps

DATEDIFF(

-- select datediff granularity (here in milliseconds)

ms,

-- select timestamp column

<table_name>."Timestamp" ,

-- select ETA timestamp of first 'Order Received' Activity

PU_FIRST(

-- set the first column as case reference domain, i.e. the PU-function uses this column

-- to select the rows that should be compaired.

DOMAIN_TABLE(<table_name>."Case_ID"),

-- select column of which the first timestamp should be taken

<table_name>."ETA",

-- set filter to only use the order received row

Activity = 'Order received'

)

) > 0 -- select if datediff should be higher or lower than zero

THEN 1.0

ELSE 0.0

END

 

Hope that this works for you!

 

Kind regards,

Jan-peter


janpeter.van.d
Level 8
Forum|alt.badge.img+19
janpeter.van.d wrote:

Hi @1461001156,

 

In the column Delay, you could put something like this:

 

CASE

WHEN

-- get the difference of two timestamps

DATEDIFF(

-- select datediff granularity (here in milliseconds)

ms,

-- select timestamp column

<table_name>."Timestamp" ,

-- select ETA timestamp of first 'Order Received' Activity

PU_FIRST(

-- set the first column as case reference domain, i.e. the PU-function uses this column

-- to select the rows that should be compaired.

DOMAIN_TABLE(<table_name>."Case_ID"),

-- select column of which the first timestamp should be taken

<table_name>."ETA",

-- set filter to only use the order received row

Activity = 'Order received'

)

) > 0 -- select if datediff should be higher or lower than zero

THEN 1.0

ELSE 0.0

END

 

Hope that this works for you!

 

Kind regards,

Jan-peter

See that the markup is deleted, sorry for that!

 


Hi @janpeter.van.d , thanks so much for your detailed answer! I guess this could work, however, it says that column "ETA" can't be found (I guess it's because "ETA" is a column which I manually created as an attribute). Is there a way how I can make the column visibile (e.g. changing a setting in the attribute)...?


janpeter.van.d wrote:

Hi @1461001156,

 

In the column Delay, you could put something like this:

 

CASE

WHEN

-- get the difference of two timestamps

DATEDIFF(

-- select datediff granularity (here in milliseconds)

ms,

-- select timestamp column

<table_name>."Timestamp" ,

-- select ETA timestamp of first 'Order Received' Activity

PU_FIRST(

-- set the first column as case reference domain, i.e. the PU-function uses this column

-- to select the rows that should be compaired.

DOMAIN_TABLE(<table_name>."Case_ID"),

-- select column of which the first timestamp should be taken

<table_name>."ETA",

-- set filter to only use the order received row

Activity = 'Order received'

)

) > 0 -- select if datediff should be higher or lower than zero

THEN 1.0

ELSE 0.0

END

 

Hope that this works for you!

 

Kind regards,

Jan-peter

As you can see in the Screenshot, the column is somehow unknown (I created it as an attribute). Do you know a way how i can make it visible?


Forum|alt.badge.img+13

@1461001156 

What are you using to define ETA as an attribute?

 

If you used a PQL expression to create it, simply replace your <table_name>."ETA" with the PQL expression you used to create the ETA attribute in the PU function, and it should work.

 

Separately, when using PU_FIRST I would definitely recommend using ORDER BY expression to make sure you are truly pulling the first value. Alternatively, you can use PU_MIN, in that case it will pick up the earliest timestamp regardless of order in the underlying table.

 

 

Eugene

 


janpeter.van.d
Level 8
Forum|alt.badge.img+19
.146101030 wrote:

As you can see in the Screenshot, the column is somehow unknown (I created it as an attribute). Do you know a way how i can make it visible?

Hi @1461001156,

 

See the answer of @Eugene Em below. Hopefully that works!

 

Kind regards,

Jan-peter


Reply