Is there a limited number of conditions that can be added in the CASE WHEN function?

Hello community,

at the moment I´m working on defining a drop down bottom to filter Production Order having “Bad Conditions” or without “Bad Conditions”.
To do so, I use a code like the one below.

Unfortunately, the amount of possible Bad Conditions is so high that after a certain number of
MATCH_PROCESS I get the error:

But if I separate the formula in 2 pieces, then I get the desired result.
However, I´m not able to combine the 2 pieces together and I should have multiple drop down lists as a filter… not practical.
image
Do you have better ideas?
At least do we know if there is a real limited number of conditions that can be added in the CASE WHEN function?

Many thanks,
Francesca

CASE WHEN
** MATCH_PROCESS** (
LOOP[‘A’] AS loop_A,
LOOP[‘B’] AS loop_B,
LOOP[‘C’] AS loop_C
CONNECTED BY DIRECT [loop_A, loop_B], DIRECT [loop_B, loop_C])>0
OR **
** MATCH_PROCESS
(
LOOP[‘A’] AS loop_A,
LOOP[‘B’] AS loop_B,
LOOP[‘D’] AS loop_D
CONNECTED BY DIRECT [loop_A, loop_B], DIRECT [loop_B, loop_D])>0
OR **
** MATCH_PROCESS
(
LOOP[‘H’] AS loop_H,
LOOP[‘G’] AS loop_G,
LOOP[‘C’] AS loop_C
CONNECTED BY DIRECT [loop_H, loop_G], DIRECT [loop_G, loop_C])>0
**OR **

OR
MATCH_PROCESS (
LOOP[‘A’] AS loop_A,
LOOP[‘G’] AS loop_G,
LOOP[‘D’] AS loop_D
CONNECTED BY DIRECT [loop_A, loop_G], DIRECT [loop_G, loop_D])>0

THEN ‘PO withBad Conditions’
ELSE ‘PO wo Bad Conditions’
END

Hi Francesca,

Thanks for your feedback. We are looking into the error message you sent. How many ORs do you use? Which Celonis version do you use?

Since CPM4.5 and IBC you can use MATCH_PROCESS_REGEX that might simplify your life depending on the use case. It also allows to assign labels 1 or 0 to cases if they match the pattern.
Below I first assign aliases to direct connections of one or more occurrences of ‘A’, … .
I then say that the process matches if the connection AB is eventually followed by BC, and so on.

CASE WHEN
MATCH_PROCESS_REGEX( "activities"."activity", 
(('A')+ >> ('B')+) as AB,
(('B')+ >> ('C')+) as BC,
(('B')+ >> ('D')+) as BD,
(('H')+ >> ('G')+) as HG,
(('G')+ >> ('C')+) as GC,
(('A')+ >> ('G')+) as AG,
(('G')+ >> ('D')+) as GD,
(AB >> (ANY)* >> BC) |
(BC >> (ANY)* >> AB) |
(AB >> (ANY)* >> BD) |
(BD >> (ANY)* >> AB) |
(HG >> (ANY)* >> GC) |
(GC >> (ANY)* >> HG) |
(AG >> (ANY)* >> GD) |
(GD >> (ANY)* >> AG)) = 1
THEN 'PO with bad conditions'
ELSE 'PO without bad conditions'
END

Does this work for you? Kind regards,
Max

Hello Max,

thanks for your reply and apologies for the late answer, due to holidays.

Celonis 4.5. The amount of OR is about 150.

However, I tested the Match_Process_regex, and indeed it provides a more efficient way to select a CASE based on a complex possibility of activities sequences (all possible bad scenario, so to speak).

Thanks again. Problem solved!

Ciao,
Francesca

1 Like