Add more advanced string handling functions to the String Builder data reference
I would like to use some more advanced string functions such as Split, Len (string length), and even regex filtering to allow more fine grained control of how some input strings (such as attribute values or substitution parameters) are manipulated to create a new string output.
Steven I have multiple PI Points with names that are similar to a generic AF structure but have to have special characters, sometimes it is simple like multiple underscores added to the name. the problem is the underscores do not always fall in the same location. right now I have a lookup table that is based on the length of the name to look up a string field that has one or more underscore characters in the column. If I had an InStr() function I could fined the occurrence of the first underscore and modify the string. Really I did not post this request in the hopes someone could come up with some "work around" for some simple string handling functionality that has been around in VBA since the '90s. You have Len(), Right(), and Left(). InStr() would add a significant increase in capability. Hopefully I don't need to explain the value
Hi Dan, can you give some examples of what you're looking to do? Your comment doesn't provide enough information for me to understand what problems you're trying to solve.
Even having InStr() would be a great help. What good are Left(), Right() etc. except in the simplest of use cases. And the answer "Use an analysis" is ridiculous. The servers have enough trouble keeping up with all the analytics already
I rally want the ability to do more advanced String operations in String builder.
Since the PI system is not only a analysis tool, it is also a foundation to store asset information.
In response to Jagdish Konathala, "Thanks Steve. We had issues upgrading to..."
Yes, SP2a does fix the installation issue with SQL Server AlwaysOn Availability groups.
In response to Stephen Kwan, "AF 2018 SP2a has a new feature for split..."
Thanks Steve. We had issues upgrading to AF 2018 SP2 since we use SQL AlwaysOn groups. Hopefully that is fixed in SP2a. Will upgrade and test the split functionality. The workaround we employed is convoluted, thanks for the split feature!
In response to Stephen Kwan, "AF 2018 SP2a has a new feature for split..."
That's a great step for Analytics, and I'll have to have a look at how it works. Would still like to see this in the StringBuilder DR as well, given the way this DR is often used for dynamically generating a tag name to be used in the PI Point DR.
AF 2018 SP2a has a new feature for splitting strings. Please see release note:
144299 - Split function was added to Expression and Event Frame Generation analyses to split a string into a string array.
Splitting on a separator (.,-) could help with separating a string. Split('MyText.YourText', '.') => 'MyText'. Will this be possible?
In response to Chris Beaupre, "A String Length and Basic Delimiter func..."
Can you help me understand what you're trying to do with tabular alarm data? As you know, an AF data reference such as the string builder is only executed on demand by the client. In order to have a fruitful discussion, it would be great if we can get some details on your use cases.
Chris Beaupre commented
A String Length and Basic Delimiter function needs to be part of the core string builder functionality. This would solve a lot of issues with handling tabular alarm data.
I may have discovered a side effect using the analysis to populate an event frame with the formatted value. Each time the EF creates a child, it appears that PI re-executes the analysis. If both the raw numeric value and the formatted string are stored in the EF, they may be different.
I have an analysis that executes every 15 minutes. It stores the raw numeric data and the formatted string in separate AF attributes. I have a second event triggered analysis that creates an event frame if the raw numeric value exceeds it's Hi Limit. The EF contains the raw numeric value as it was when the original EF was created but the formatted string contains the current value.
The ability to format the string in String Builder would eliminate the need for two attributes and this potential discrepancy.
Using the string builder interface is confusing. The best method that I've found is to click the right arrow ">", look for the function, reference, etc. that I need and then type it in on another line. I've worked with at least two support engineers that have had similar problems when helping me via a Bomgar session.
We would like to see a format string that formats a number to a string and inserts commas in the appropriate positions. Example number 9999999 formats to 9,999,999
along with decimals, currency, etc. Our primary use is when data from an event frame is included in a notification.
String builder could also be used to read the data from the PI Archive and format it into the Event Frame attributes as a string.
John Hosmer commented
Additionally, in case 00563064 we are attempting to format integers with comma thousand separators (123456789 --> 123,456,789). This is not possible with the current string builder function support (2018 SP1).
Introducing the Len() PE function among other functions that have been suggested so far would enable users to format strings of variable length.
Bruce C. McCamant commented
See Support case 960088; trying to create a reference to a child attribute in another branch in an AF template. That attribute value is static content.
Jason Bray commented
I would love to see a basic if/then/else function added to String Builder. In some cases, I can work around it using Replace or other functions, but I have had to abandon dozens of attempts where I want a string attribute to depend on some other attribute's value, and found it impossible. An IF function would have been perfect each time.
Idris Lazuardi commented
Just to add to this, another use case is to get the root element of the current element path (as opposed to the parent element).
As an example, I can create an attribute "SitePath" with %ElementPath% and it will get me a value as something like below:
To get the 2nd element from the root (i.e. "Element1.1"), I would have to do this in Analytics with the combination of following functions:
Which is not possible with String Builder.
(Unless there is already a substitution parameter to get me the element FROM the top down, instead from the bottom up)
Luke Yarnall commented
An additional capability that would be good is the ability to parse a string by delimiters. This would be helpful when tracking alarms and events from the Interface for OPC AE. OPC AE messages are sent as a pipe (|) delimited string and stored as string PI tags.
For alarm and event tracking with event frames, it is useful to split the pipe delimited string and store each alarm attribute as an AF child attribute.
Currently this must be done in asset analytics using the InStr function, which is not available in String Builder.
I've attached a relevant tech support case to this enhancement request.
In response to Stephen Kwan, "John, What are you trying to do? Are yo..."
That wasn't my original use case, but these would probably be easier to parse with some of these kind of functions. I'm more looking at parsing various string elements for PI tag name resolution - some of my customers (and one in particular where I have a couple of current projects) use some very nicely consistent naming conventions, and being able to dynamically resolve tag names from asset string data would be easier with some of these functions.