# Compare Signals in Formula

Go to solution Solved by Ben Johnson,

## Recommended Posts

• Seeq Team

Can I compare signals in Formula to create conditions rather than doing a Value Search?

Edited by Kelly Kolotka
##### Share on other sites

• Seeq Team
• Solution

When creating a value based condition, the usual default is the Identify -> Value Search tool, but it is also possible using Formula with common math operators like <, <=, >, >=, == (is equal to), != (is not equal to), and && (logical and) for use as signal against scalar, or signal against signal comparisons!

Whenever the mathematical condition is met, a condition will be created just like a typical Value Search. For more information, search for "Comparisons" in your formula documentation.

Here are a few examples of these operators in use:

Signal and scalar comparison:

Signal and scalar comparison with logical and:

Signal against Signal:

In addition to the common math symbols, there are also some new concise ways to search for other signal states:

• \$signal.isValid() - make a condition that enumerates when the signal has data
• \$signal.isNotValid() - make a condition that enumerates the gaps in the signal
• \$signal.isBetween(10, 20) - make a condition whenever the signal is between 10 and 20
• \$signal.isNotBetween(10, 20) - make a condition whenever the signal is outside the boundary of 10-20

Also for string signals, you can search for regular expressions or glob-like syntax:

• \$signal ~= "*STAG*" - find whenever the state signal contains "STAG".
• \$signal !~ "*STAG*" - find whenever the state signal does not contain "STAG".

All of these things can be combined and given precedence with parenthesis. For example, to find "when is temp < 90 and either of humidity > 60 or compressor is off "

`\$temp < 90 && ( \$humidity > 60 || \$compressor == 'OFF')`

Content Verified DEC2023

Edited by Kelly Kolotka
• 1
##### Share on other sites

• Kelly Kolotka changed the title to Compare Signals in Formula