Question
Count cases with condition
Dear Team.
I need to calculate count of cases with condition.
Condition is, when case appeared in the period from 0 to 10 days. I gave an example of the calculation below, but unfortunately I cant be sure that it is correct. Please, read and give a feedback.
CASE WHEN
AVG (DAYS_BETWEEN(SOURCE (DB_EVENTS.EVENT_SDTS, CALC_CROP(FIRST_OCCURRENCE[MY_EVENTS1] TO LAST_OCCURRENCE[MY_EVENTS2],
CASE
WHEN DB_EVENTS.EVENT_NAME LIKE Event_1% THEN MY_EVENTS1
WHEN DB_EVENTS.EVENT_NAME LIKE Event_2% THEN MY_EVENTS2
ELSE DB_EVENTS.EVENT_NAME END),
FIRST_OCCURRENCE TO LAST_OCCURRENCE
),
TARGET(DB_EVENTS.EVENT_SDTS)
))>0
AND
AVG (DAYS_BETWEEN(SOURCE (DB_EVENTS.EVENT_SDTS, CALC_CROP(FIRST_OCCURRENCE[MY_EVENTS1] TO LAST_OCCURRENCE[MY_EVENTS2],
CASE
WHEN DB_EVENTS.EVENT_NAME LIKE Event_1% THEN MY_EVENTS1
WHEN DB_EVENTS.EVENT_NAME LIKE Event_2% THEN MY_EVENTS2
ELSE DB_EVENTS.EVENT_NAME END),
FIRST_OCCURRENCE TO LAST_OCCURRENCE
),
TARGET(DB_EVENTS.EVENT_SDTS)
))<10
THEN COUNT_TABLE(DB_CASES) ELSE NULL END
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
By using this specifier you only consider the the first and last activity for your source target operation. With regards to the remaining process flow above that perfectly works as we skip activity C or any further activities in between.
The surrounding PQL statement are
AVG(
DAYS_BETWEEN(
//SOURCE TARGET //CROP
))
which calculate the days_between for all cases and take the average.
Attention: Bear in mind that this formula does not take cases into account that show the starting activity MY_EVENTS1 but have not yet reached the target activity MY_EVENTS2.