Skip to main content
Jul 31, 2023 9:24 AM UTC
Question

Hi I need to create a new formula to calculate the total number of cases by day, filtering by some condition. Some one can help me?

I am using this formula but I know that is not right. :

AVG(PU_COUNT ("_X_INC_CASE", ROUND_DAY("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME"), KPI("Efficient Conditions_ All Reopen") = 'Efficient'))

 

The X_INC_CASE has unique values and the X_INC_SECONDARY_ACTIVITIES has all events

15 replies

Jul 31, 2023 10:17 AM UTC

Hi Daisy,

 

For filtering in PQL I usually use CASE WHEN statements:

https://docs.celonis.com/en/case-when.html

 

I normally wrap this around a Count or Sum formula. Avg may also for for you.

Jul 31, 2023 10:19 AM UTC

Hi @daisy.enriq​,

try this Formula:

 

here you will get for each day the total number of cases filtered by your condition (as Table)

PU_COUNT_DISTINCT (

  Domain_table ( ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) ,

  "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

  your condition

 )

you can add the AVG() to the formula to get the KPI (single number)

Jul 31, 2023 10:26 AM UTC

Hi @daisy.enriq​,

try this Formula:

 

here you will get for each day the total number of cases filtered by your condition (as Table)

PU_COUNT_DISTINCT (

  Domain_table ( ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) ,

  "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

  your condition

 )

you can add the AVG() to the formula to get the KPI (single number)

As above although, as Daisy wants to group be case and day, it will be

PU_COUNT_DISTINCT (

 

 Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) , "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

 your condition

 )

Jul 31, 2023 10:27 AM UTC

Hi Daisy,

 

For filtering in PQL I usually use CASE WHEN statements:

https://docs.celonis.com/en/case-when.html

 

I normally wrap this around a Count or Sum formula. Avg may also for for you.

Thankss , I already tested that approach but gave me an error, something about that we can not use CASE WHEN with Count aggregation.

 

Jul 31, 2023 10:37 AM UTC

As above although, as Daisy wants to group be case and day, it will be

PU_COUNT_DISTINCT (

 

 Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) , "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

 your condition

 )

Hi @Guillermo Gost​,

 

yes! If @daisy.enriq​ wants to group more by case that should be the solution.

 

But @Guillermo Gost​  wouldn't be right to use a PU_COUNT instead of a PU_COUNT_DISTINCT in this situation?

Jul 31, 2023 10:53 AM UTC

Hi @daisy.enriq​,

try this Formula:

 

here you will get for each day the total number of cases filtered by your condition (as Table)

PU_COUNT_DISTINCT (

  Domain_table ( ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) ,

  "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

  your condition

 )

you can add the AVG() to the formula to get the KPI (single number)

This formula seems to work well

 

PU_COUNT_DISTINCT (

  Domain_table ( ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) ,

  "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

  your condition

 )

 

Basically I need to get the same value that appear on the Cases per day on the Process Overview Cheet, that Celonis generate automatically. It is not matching for now, but maybe is some filter or the data model, I need to check. 

 

I also, tried this one :  Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) , "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

 your condition

 )

 

But the results are juts 0 and 1

 

Thanks both for the help

Jul 31, 2023 10:55 AM UTC

As above although, as Daisy wants to group be case and day, it will be

PU_COUNT_DISTINCT (

 

 Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) , "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

 your condition

 )

Hmmm... I misread the question. Number of cases per day.

 

Then

 

PU_COUNT_DISTINCT(ROUND_DAY(activities.eventime),CASE_TABLE().CASE_ID)

 

(or activities.case_id)

 

COUNT_DISTINCT as she wants the number of cases, not the number of activities. Although if you group by day the case_table it will be the same, if for any reason you point to activities with count you will get 1 per each activity per case, I think

 

As a thumb rule I tend to use COUNT_DISTINCT over SUM or COUNT.

 

HTH

Jul 31, 2023 11:00 AM UTC

Hi Daisy,

 

i am glad that it worked well :)

 

 

Jul 31, 2023 11:04 AM UTC

This formula seems to work well

 

PU_COUNT_DISTINCT (

  Domain_table ( ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) ,

  "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

  your condition

 )

 

Basically I need to get the same value that appear on the Cases per day on the Process Overview Cheet, that Celonis generate automatically. It is not matching for now, but maybe is some filter or the data model, I need to check. 

 

I also, tried this one :  Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) , "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

 your condition

 )

 

But the results are juts 0 and 1

 

Thanks both for the help

If you want on the Cases per day just replace the above Formula of @Guillermo Gost​  PU_COUNT_DISTINCT with PU_COUNT, so you will get values greater than 1

Jul 31, 2023 11:43 AM UTC

As above although, as Daisy wants to group be case and day, it will be

PU_COUNT_DISTINCT (

 

 Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" ) , "_X_INC_SECONDARY_ACTIVITIES"."CASE_ID" ,

 your condition

 )

sure no problem :)

 

yes my abvove formula is right as it is with the distinct.

 

when we want to use this as Domain Table (your first response):

Domain_table (

CASE_TABLE().CASE_KEY,

ROUND_DAY ("_X_INC_SECONDARY_ACTIVITIES"."_EVENTTIME" )

we point to another question: per case, how often that same case appears on a specific day? so I think removing the disctinct is better, otherwise the result will be either 1 or 0. So the number of activities in a case is related to how often a case on a specific day appears.

 

I am glad anyway that we could help Daisy together. Thanks for the conversation Guillermo :)