Skip to main content

Hi!

I have a doubt about a calculation related to the duration between activities.

 

Normally the CALC THROUGHPUT formula is used to calculate durations between 2 activities.

However, I need to calculate the duration between more than 2 activities in a single KPI (e.g. the duration between activities A and B to activity C, or from A and B to C and D), but I can't get the formula.

 

I already have tried the following formula to calculare the duration between activities 'A' and 'C' to 'B'

 

AVG 

(

CASE

WHEN PROCESS EQUALS 'A' TO ANY TO 'B'

 

THEN CALC_THROUGHPUT(FIRST_OCCURRENCER'A'] TO LAST_OCCURRENCER'B'], 

 

REMAP_TIMESTAMPS("activity_table"."timestamp"))

 

 

WHEN PROCESS EQUALS 'C' TO ANY TO 'B'

 

THEN CALC_THROUGHPUT(FIRST_OCCURRENCEO'C'] TO LAST_OCCURRENCEO'B'], 

 

REMAP_TIMESTAMPS("activity_table"."timestamp", HOURS))

 

ELSE 0 END 

)

 

 

Can you help me?

 

Thank you very much!!

Hi @Agustín Muñoz ,

 

First of all, if I understand your question correctly, you want to calculate the (average) throughput between the first occurrence of either A or B to the first occurrence of C or D? I'm a bit confused by what you mean with 'A and B to C and D'.

 

Second, your code snippet could work but I see two issues:

  1. Both THEN statements are different, so you're averaging days (I guess) with hours
  2. The ELSE 0 part messes up the result of AVG. It's best to return NULL instead (these values get ignored by AVG, whereas 0 is considered as a valid value, hence lowering the result).

I hope these two hints already help. Otherwise please provide clarification on what you are exactly looking for.


Hi!

I am sorry, It could be a bit complex.

I am going to give you an example: imagine that we have 3 different activities:

  • Order confirmation
  • Order confirmation - Automatism
  • Order recieved

The KPI I want to calculate is the average duration from the first occurrence of 'Order confirmation' or 'Order confirmation - Automatism' to the first 'Order received'.

For this, I need a formula that calculate the duration between the first "Order confirmation" or "Order confirmation - Automatism" (which one occurs first) and first "Order recieved", but I dont know how to get it.

Thank you sou much,

Agustín


My first thought is a construct like this:

 

AVG(DATE_DIFF(dd,

PU_FIRST(case_table,activity_table.timestamp, activity_table.name IN ('Order confirmation ','Order confirmation - Automatism')),

PU_LAST(case_table,activity_table.timestamp, activity_table.name = 'Order recieved')

)

 

Could you try this and me let/us know?


Thank you so much!!! It works perfectly.

 

Best regards,

Agustín


Reply