Skip to main content
PI System
PI DataLink
Performance Equations
How-to

How to Use the Instr Function in PI DataLink Performance Equations for Digital State Filtering

Learn how to use the Instr function in PI DataLink Performance Equations to filter digital tags containing variations of "STOP", troubleshoot syntax errors, and utilize official resources for expression building.

Roshan Soni

4 min read

Leveraging the Instr Function in PI DataLink Performance Equations: A Guide for Digital Tag Filtering

When working with OSIsoft PI DataLink, Performance Equations (PEs) can empower users to perform complex logic-driven queries directly within their Excel reports. One common need is to identify digital tags containing a specific substring, such as various forms of "STOP" (e.g., "stopped", "stop/in_field"). In this post, we'll walk through how to use the Instr function within DataLink Performance Equations, and how to troubleshoot syntax errors for effective digital state filtering.

Understanding the Instr Function in Performance Equations

The Instr function is a string search function available in PI Performance Equations (PEs). Its typical format is:

Instr ( String, Substring )
  • String: This is the main text you want to search.
  • Substring: The sequence of characters you want to look for within the string.

The function returns the position of the substring within the string (position is 1-based). If the substring is not found, it returns 0.

Typical Use Case: Filtering Digital Tags for Variations of "STOP"

Suppose you have a tag whose value could be "stopped", "stopped/in_field", "stop/in_field", etc. To determine if the tag value includes the word "STOP", you can use:

Instr('tagname', "STOP") > 0

This expression evaluates to True if "STOP" is anywhere in the tag value, regardless of the extra text before or after.

Common Syntax Issues and Solutions

If you're seeing an "invalid expression syntax" error, check for these common pitfalls:

  1. String Quotes: Performance Equation expects string literals in double quotes. For tag names or static strings, use double quotes ("STOP"). For tag references, use single quotes around the tag name, without quotes around the tag reference itself.
  2. Correct Function Case: PI PEs are case-insensitive, but consistency helps readability (Instr).
  3. Argument Types: Ensure the first argument returns a string. For example, Instr('tagname', "STOP") is correct if the PI tag ('tagname') has textual values.

Example Expression

Instr('MyDigitalTag', "STOP") > 0

This returns True if the string value of 'MyDigitalTag' contains "STOP".

Helpful References

OSIsoft provides a comprehensive Performance Equation Reference Manual. You can find this in the PIPC\HELP directory as PEReference.chm (e.g., C:\Program Files (x86)\PIPC\HELP\PEReference.chm). This guide lists all functions, usage examples, and operator details helpful for troubleshooting and advanced expressions.

Final Tips

  • Always validate your expression by entering it in DataLink or PI System Explorer (where applicable) and checking for syntax errors.
  • If errors persist, break your equation into smaller parts and test each segment.
  • Consult the official PE Reference for exact syntax details on all supported functions.

Have expressions that still won’t work? Share your syntax and error message—the PE community is always ready to help!

Tags

#PI DataLink
#Performance Equation
#Instr
#String Search
#Digital Tag Filtering
#Syntax Error

About Roshan Soni

Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.

Sign in to comment

Join the conversation by signing in to your account.

Comments (0)

No comments yet

Be the first to share your thoughts on this article.

Related Articles

Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead

A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.

Roshan Soni

Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB

Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.

Roshan Soni

Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?

Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.

Roshan Soni

    How to Use the Instr Function in PI DataLink Performance Equations for Digital State Filtering | Pisharp Blog | PISharp