AnsweredAssumed Answered

Creating a calculated field with Case and Or

Question asked by dwirony on Jul 30, 2018
Latest reply on Jul 31, 2018 by TKnTexas55

I'm trying to create a calculated field with a case statement involving multiple criteria - to include multiple criteria I'm trying to use "or".

 

I can see that the base syntax for "Case" is:

 

Case ( test1 ; result1 {; test2 ; result2 ; ... ; defaultResult}

 

I want to say "If myfield1 = "Red" or "Blue" or "Green", 1" - then my next case would be "If myfield1 = "Purple" or "Yellow" or "Orange", 2"

 

I'd rather use Case instead of a long If/Else statement - this calculated field will only return the number 1, 2 or 3, but I have 15-20 possible entries for each one - how can I write this in a simple manner to which I can make edits/revisions in the future?

 

My first attempt:

 

Case ( myfield1 = "Red" or myfield1 = "Blue" or myfield1 = "Green" ; 1 {; myfield1 = "Purple" or myfield1 = "Yellow" or myfield1 = "Orange" ; 2 ; ... ; defaultResult} )

 

This will look very confusing with ~60 possible criterias.

Outcomes