IFBAD
- Last UpdatedMar 03, 2025
- 1 minute read
The IFBAD() function overrides "bad" quality values with an alternative value.
Syntax
|
Format |
Stream = IFBAD( Stream, AltValue ) |
|
Arguments |
Stream - A stream of values AltValue - The value with which to replace "bad" quality values |
|
Description |
Replaces every value in the input stream that has a "bad" OPC quality with AltValue. |
|
Format |
Stream = IFBAD( Stream, AltStream ) |
|
Arguments |
Stream - A stream of values AltStream - A stream of replacement values |
|
Description |
Replaces every value in the input stream that has a "bad" OPC quality with the value from AltStream at the corresponding time. |
Example 1
This example uses the following tag name:
-
Pump101.Flow measures the flow rate of a pump in liters per second (L/s)
The following expression returns the flow rate of a pump, but any "bad" quality values are replaced with -1.
IFBAD( Pump101.Flow, -1 )
Example 2
The following expression
IFBAD( 60 / SysTimeSec, -1 )
Example 3
This example uses the following tag names:
-
Pump101.Flow measures the flow rate of a pump in liters per second (L/s)
-
Pump102.Flow measures the flow rate of a pump in liters per minute (L/min)
The following expression returns the flow rate of a pump, but any "bad" quality values are replaced with the value from a second pump at the corresponding time.
IFBAD( Pump101.Flow, Pump102.Flow )
The units for each tag in the expression are implicitly converted to match the units of the first tag, so the expression's results are in liters per second.