Skip to main content
Question

Hi everyone! I am trying to create a case when where it will say 'Yes' or 'No' depending on the conditions. But it´s not taking any actions, not sure why..

  • January 24, 2024
  • 2 replies
  • 1 view

CASE WHEN SUBSTRING ( "VBAP"."MATNR", 0, 2 ) = '60' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 2 ) = '64' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '647731' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '664402' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '664403' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '666161' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '666162' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '666931' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '666986' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '666987' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '669181' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '669182' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '669183' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '669184' then 'Yes'

 WHEN SUBSTRING ( "VBAP"."MATNR", 0, 6 ) = '666651-001' then 'Yes'

ELSE 'No'

END

 

the first condition is not being applied, I see materials that starts with 60 o 64 with a no, I tested on the background and it is returning the value..

2 replies

Sverre Klein
Level 10
Forum|alt.badge.img+14
  • Level 10
  • January 24, 2024

Hi Joyce,

 

If I got your problem correct, you want MATNR values that start with '60' or '64', and map them to 'yes', however the value 'no' is returned.

 

I think the problem lies in that you are trying to get the exact value '60' and '64', not that it starts with '60' or '64', you need to use the LIKE function instead of =

 

The code will look like follows. (pun not intended 😂 )

 

CASE WHEN "VBAP"."MATNR" LIKE '60%' THEN 'Yes'

   WHEN "VBAP"."MATNR" LIKE '64%' THEN 'Yes'

 

The % will act as a wildcard for any value that comes after '60' and '64' respectively.

 

Let me know if this resolved your problem or if you need more help 😊

 


janpeter.van.d
Level 12
Forum|alt.badge.img+26

Hi @joyce.cardo12,

 

If you always want to return 'Yes', the suggestion of @sverre.klein11 could be reduced by using the IN_LIKE operator (see IN_LIKE (celonis.com)).

 

Your statement will be:

 

CASE

WHEN "VBAP"."MATNR" IN_LIKE ( '60%' ,  '64%' , '647731%' ......) THEN 'Yes'

ELSE 'No'

END