AnsweredAssumed Answered

What is the PI performance equation syntax equivalent to this Analytics expression?

Question asked by SvenBatalla on Sep 2, 2015
Latest reply on Sep 2, 2015 by SvenBatalla

I have built an Analytics expression that works great for my needs in AF but does not work when used in the FilteredSummaries call.  I get an error citing an invalid PI performance equation.  The expression is below (in C#):


@"(BadVal('Is Masked') OR 'Is Masked' = false) AND Not(BadVal('Source Tag')) AND Compare(Concat(""*|"", 'Source Tag', ""|*""), Concat(""|"", 'Abnormal States', ""|""), false)"


As you may be able to guess from the contents of the expression, I have an element with 3 relevant attributes that are all PI tags:



|- Abnormal States

|- Is Masked

|- Source Tag



The "Abnormal States" attribute is a string tag that contains a pipe-delimited list of possible digital states.  For example, "Phase1|Phase3".

The "Is Masked" attribute is a Boolean tag (well, int) that will only ever be true, false, or bad.

The "Source Tag" attribute is a digital tag.


The expression (which again works in AF) first checks if the "Is Masked" tag is bad or false.  This indicates that the calculation is NOT masked and can resume.  Next, the calculation makes sure the value in the "Source Tag" attribute is good.  If all is well to this point, that's where the action happens...  First, the value of the "Source Tag" attribute is wrapped with pipes.  So if the value is "Phase1", the string "|Phase1|" is constructed.  Next, the value of the "Abnormal States" tag is read and wrapped with pipes as well.  So if we use that example from before, the string "|Phase1|Phase3|" would be constructed.  Finally, the source string is compared to the state string (case insensitive).  So the expression breaks down like this:


// Assume:
//  - Is Masked: false
//  - Source Tag: Phase1
//  - Abnormal States: Phase1|Phase3
// Then:
// (BadVal('Is Masked') OR 'Is Masked' = false) AND Not(BadVal('Source Tag')) AND Compare(Concat("*|", 'Source Tag', "|*"), Concat("|", 'Abnormal States', "|"), false)
// (BadVal(false) OR false = false) AND Not(BadVal("Phase1")) AND Compare(Concat("*|", "Phase1", "|*"), Concat("|", "Phase1|Phase3", "|"), false)
// (BadVal(false) OR false = false) AND Not(BadVal("Phase1")) AND Compare(Concat("*|Phase1|*"), Concat("|Phase1|Phase3|"), false)
// (false OR true) AND Not(false) AND Compare(Concat("*|Phase1|*"), Concat("|Phase1|Phase3|"), false)
// (true) AND true AND Compare(Concat("*|Phase1|*"), Concat("|Phase1|Phase3|"), false)
// true AND true AND true
// true


If the expression evaluates to a positive result, the FilteredSummaries call I've implemented will count the value from the "Source Tag" attribute.  My goal is to count all the values in a given time range that meet the expectations of this expression.