Skip to main content
Question

How do I use PU_FIRST and PU_LAST function to calculate the total wait time between my operations?

  • March 15, 2023
  • 4 replies
  • 35 views

I have cases table with _CASE_KEY and OPERATION NUMBER. Each _CASE_KEY can have N operations. For ex:

_CASE_KEY: 01000200

  1. OPERATION 0001
  2. OPERATION 0100
  3. OPERATION 0500
  4. OPERATION 0700 (etc)

_CASE_KEY: 03000200

  1. OPERATION 0001
  2. OPERATION 0100
  3. OPERATION 0500
  4. OPERATION 0700 (etc)

The goal is to calculate the time it takes from last operation of a case to first operation of the next case. In the example above, it would be time difference between the _CASE_KEY 01000200, OPERATION 0700 to _CASE_KEY 03000200, OPERATION 0001. I am trying to use the PU_FIRST and PU_LAST to accomplish this goal but unfortunately it is NOT giving me what I am looking for. Any help would be appreciated. I do have the ACTIVITIES table where all of these operations that I've mentioned above are shown.

 

4 replies

Are operations modeled as Activities?


  • Author
  • Level 2
  • March 16, 2023

Hi Yes, the operations are incorporated to form the activities. Giving the Above example

_CASE_KEY: 01000200

  • OPERATION 0001
  1. ACTIVITY 1 [0001] - Create
    1. ACTIVITY 2 [0001] - Modify
    2. ACTIVITY 3 [0001] - Delete
  • OPERATION 0100
  1. ACTIVITY 1 [0001] - Create
    1. ACTIVITY 2 [0001] - Modify
    2. ACTIVITY 3 [0001] - Delete

The same structure gets repeated for all of the CASES and each case can have N operations.


Ok... here the main problem is to define "next" case... as we expect the cases are not sequential.

 

But let's imagine you have a way to know which is the next case.

 

To know the first activity of a case you can use INDEX_ACTIVITY_ORDER and look for the one with 1

https://docs.celonis.com/en/index_activity_order.html

 

The last one is more tricky.... you can use INDEX_ACTIVITY_ORDER combined with count_table(activity_table) to know how many activities has a case, then search for the activity with INDEX_ACTIVITY_ORDER.

 

Also you can use PU_MAX(CASE_TABLE, ACTIVITY_TABLE.EVENTTIME) to get the last activity per case.

 

Also INDEX_ORDER can help

https://docs.celonis.com/en/index_order.html

 

Maybe combining the above ideas you can get what you want. A lot depends on, for starters, how to identify the "next" case. And if you need this as a single KPI, combined in a OLAP table, etc....

 

HTH

 


  • Author
  • Level 2
  • March 20, 2023

Hi @Guillermo Gost , I was able to get what I wanted using the Source and Target. Thank you for your help!