# Calculate throughput from one activity to another

#1

Hello everyone,
I am having a process in a form Activity1->Activity2->Activity2->Activity3->Activity4->Activity2->Activity2->Activity4
(1)-----------(2)-----------(3)----------(4)------------(5)--------(6)-------------(7)----------(8)
and interested in calculating the days between the Activity3 and the first Activity2 that happens after Activity3, i.e. in the throughput time between positions (4) and (6). Any ideas how to implement it?

Thank you!

1 Like
#3

Hi.

I have not run the full check, however I believe following formula should work:
DAYS_BETWEEN(
PU_FIRST(“case”,“events”.“date”,“events”.“activity” = “Activity3”),
PU_FIRST(“case”,“events”.“date”,“events”.“activity” = “Activity2” AND
CALC_CROP(FIRST_OCCURRENCE[‘Activity3’] TO LAST_OCCURRENCE[‘Activity4’], “activity”) = 1)
)

6 Likes
#4

Hi,
the answer from nicks.si works. I only needed to adjust the quotation marks (to single quotation marks when referencing a string like ‘Activitiy3’). My full answer looks then like this. I also inserted CASE_END to CALC_CROP to generalize the answer.

``````DAYS_BETWEEN(
PU_FIRST("Activities_CASES","Activities"."Date","Activities"."Activity" = 'Activity3'),
PU_FIRST("Activities_CASES","Activities"."Date","Activities"."Activity" = 'Activity2' AND
CALC_CROP(FIRST_OCCURRENCE['Activity3'] TO CASE_END,"Activities"."Activity") = 1)
)
``````

Kind regards,
Max

4 Likes
#6

Thank you very much, it works perfectly!

#7

Is it possible to do this without PU? For example if I have only one table in data model?

#8

Hallo:)
I can imagine it could work with SOURCE and TARGET functions.

Best,
Maria

#9

Hello,

yes, you can calculate it using `SOURCE` and `TARGET`. If you’ve never used those operators before, I’d suggest to take a look at this guide: Feature of the week series #17 - Source Target . However this only works on the activity table, which is probably not the case for you if you only have one single table in your Datamodel (when specifying an Activity table, it is also guaranteed that you also have a case table).

If you are on IBC or CPM4.5, you can combine the suggested solution with the `DOMAIN_TABLE` functionality, which allows you to use PU-functions on a single table.

Best,
David