Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI System Management Tools

If-then-else expressions

  • Last UpdatedOct 04, 2024
  • 1 minute read

The if-then-else operator is a compound operator whose operands are used as follows:

if expr0 then expr1 else expr2

where expr0, expr1, and expr2 are expressions. If expr0 is true (nonzero), this operator returns the value of expr1; if expr0 is false (zero), it returns the value of expr2.

Here are some examples:

if 'tag1' > 50 then "overlimit" else "good"

if 'tag1'= 1 then Sin('tag2') else if 'tag1'= 2 then Cos('tag2') else Tan('tag2')

if 'tag3'<> "shutdown" then (if 'tag1' > 'tag2' then 'tag1' else 'tag2') else "error"

'*' + (if 'tag2' = 0 then 3600 else 0)

Note: You must include the if, the then, and the else. Nested operations are supported.

TitleResults for “How to create a CRG?”Also Available in