Hello, I am trying some formulae in saved searches...
# general
s
Hello, I am trying some formulae in saved searches results. Does anyone know how to use multiple case when statements ? I have here a sample formula but the result says formula is invalid, any thoughts why is this so? Any response is appreciated! Thanks! CASE WHEN (({job.altname} not like '%'||('Six Sigma')||'%') AND {customer} is not null) OR ({location.id} in (12,13,5,14)) OR {job.altname} like '%'||UPPER('Shop Hours')||'%' OR {job.altname} like '%'||UPPER('MJF 4200')||'%' THEN '1' WHEN (({job.altname} like '%'||('Six Sigma')||'%') OR {customer} is null) AND ({location.id} is null or {location.id} not in (12,13,5,14)) AND {job.altname} not like '%'||UPPER('Shop Hours'||'%' AND {job.altname} not like '%'||UPPER('MJF 4200')||'%') THEN '2' ELSE '0' END
s
@SmithJ Your part with
MJF 4200
has a
THEN
but no corresponding
WHEN
.
s
Hi @Sandii, this is supposed to be one case (1) when statement, CASE WHEN (({job.altname} not like '%'||('Six Sigma')||'%') AND {customer} is not null) OR ({location.id} in (12,13,5,14)) OR {job.altname} like '%'||UPPER('Shop Hours')||'%' OR {job.altname} like '%'||UPPER('MJF 4200')||'%' THEN '1'
am I missing anything in my formula?
s
It's very possible something is out of place, that is one ugly formula
s
Yes, I agree. The formula is too complicated. Do you have any idea how to use multiple case when statements in Netsuite? Does CASE WHEN.. insert condition. THEN 1 CASE WHEN.. insert condition. THEN 2 ELSE 0 END works? Thanks!
s
Yes you can chain THEN/WHEN, you can
CASE WHEN THEN WHEN THEN WHEN THEN ELSE END
; a single use of CASE can have multiple WHEN/THEN with it
s
Great! Guess I need to work on that formula to make it work, then. Thanks for your help!