Switch/Case with OR lists as input

I have a case where there are three options for a variable (localCensusDetail) based on the value of another variable (localCensusYear). There are 10 possible values of localCensus year. So I'd like to use an OR list as the Case choice

I have tried to do that in KM using comma separated values and I also tried separating with | (see screenshot) and I also tried both of those using "contains" rather than "is"

None of these formats worked (the first choice where there is only a single possible value, 1841, does work)... So is there a correct format for this or is it not a permitted way of using Switch/Case?

If the latter, is my only choice to enter one "execute" statement for each possible value of localCensusYear even though there is significant redundancy or is there a more elegant solution?

Dave

Hi, @DaveRI. The key is to use matches. See Switch/Case Action wiki page.

Here's an example:

DOWNLOAD Macro File:
Case-Switch with OR.kmmacros (13 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Macro-image

3 Likes

Wow. Many hours of fruitless fiddling on my part solved in one very clear example by you. .... and I've learned a new use for Regular Expressions (which I'm just learning).

THANK YOU!

Dave

1 Like