# How to combine value searches in formula?

## Recommended Posts

Hello -- new to the community so apologies if this is in the wrong place.

I have a signal that I would like to perform multiple value searches on to produce one condition (or set of capsules?).  For example, let's call it "Position" and I want to create a single condition that generates multiple capsules based on the value for position... i.e. when "Position" is between 10 and 20, and between 50 and 100, and between 100 and 200, etc.  The position start and end values are not always the same length, or with any periodicity.

The only way I know to do this is I create a separate "Condition from Signal" for each unique capsule, then group the capsules with "Manual Condition".

I've tried a few things based on duplicating conditions that were generated through the dialogs and modifying them, but I can't seem to get past creating more than one capsule per condition that way.

Edited by David Rowe
##### Share on other sites

• David Rowe changed the title to How to combine value searches in formula?
• Seeq Team

Hi David,

The typical way that we would recommend doing this is with individual Value Searches (where you could select between the various values) and then use Composite Condition to combine those. However, you could also do this in a single formula. For example, you may do something like:

`(\$signal > 10 and \$signal < 20) or (\$signal > 50 and \$signal < 100)`

However, if you want those to be distinct capsules, the "or" operator (equivalent to "union") would combine the capsules if you had back-to-back capsules where the end of one range started another. In this case, you could use the "combinewith" operator to combine the different logics:

```combinewith(
(\$signal > 10 and \$signal < 20),
(\$signal > 50 and \$signal < 100),
(\$signal > 100 and \$signal < 200)
)```

Another option would be to add some logic as to where they came from where a property (in this case named "Position") would tell you something about the capsules being formed. For example:

```combinewith(
(\$signal > 10 and \$signal < 20).setproperty('Position', '10-20'),
(\$signal > 50 and \$signal < 100).setproperty('Position', '50-100'),
(\$signal > 100 and \$signal < 200).setproperty('Position', '100-200')
)```