Skip to main content

Saw a similar post from a few years ago but believe my question is slightly different. I want to write PQL that calculates the difference in days between the time stamps of when a "Next Status" was entered. The image is an example of what my raw data looks like and the column in yellow is what the PQL would help calculate.

image 

Hello, I am not fully sure how to configure the formula but I think a combination of the function datediff() and lag() could help.

 

I suggest using something like this:

 

DATEDIFF(dd, LAG ("table"."timestamp" , ORDER BY ("table"."Order Number", "table"."timestamp"), 1 ), LAG ("table"."timestamp" , ORDER BY ("table"."Order Number", "table"."timestamp"), 2 ))

 

--> LAG(...., 1) gives you the previous date and LAG(...., 2) gives you the previous one. DATEDIFF(dd, ...) will calculate the difference in days between those two. Then you only need to group the values by order number or whatever makes more sense for you.

 

Please tell me if it helped


Reply