Greater than but less than condition

Is there a way to have an IF THEN condition that is a range? I’m trying to have KM do different things based on if a number is lower than say 300, and something else if it is between 301 and 4000, and another thing if it is 4001 and greater. The numbers are variables acquired at other parts so those are just examples, but essentially, I can do the greater than and less than parts, but can’t figure out the greater than BUT less than. Is this possible?

This could also be done with nested If/Then/Else, but I'd set it up with a Switch/Case.

A Switch/Case executes the actions in the Action field under the first condition that is matches, and can be set up like this to meet your criteria.

Switch-Case.kmactions (982 B)

2 Likes

Perfect, that does exactly what I want. Thanks for your guidance. Never used Switch/Case before but definitely nested multiple IF/THENs. Next step will be to adjust to Switch/Case.

1 Like

It's usually the best way to go when you've a series of contiguous ranges.

For non-contiguous you can use nested "If"s -- you can reduce the complexity by including the ranges in your Condition(s). Whether you nest them will depend on the logic.

First off, it's "AND less than", not "BUT". Which sounds picky but will help you remember how to do this:

local__number >= 301 AND local__number <= 4000

...will be true if local__number is between 301 and 4000 (inclusive, because of the = in both terms).

Demo!

Non-Contig Ranges.kmmacros (10.6 KB)

You can make these combinations pretty complicated -- if you only care if the number was within certain ranges and not which range:

(Local_number <= 10) OR (Local_number > 20 AND Local_number <= 30) OR (Local_number > 40 AND Local_number <= 50)