We use a PI AF2.0 database were we retrieve data using our own data Reference using web services. This data reference usually returns a value, but on occasions a string is returned. Now let’s say, we have a template where the data reference returns the value to Attrib1. We now make a second attribute called Atrrib2. of the type formula. Finally we have attribute 3 called Attrib3 which is a PI DataReference. So we have:
Attrib1 from web service (returning value or string)
Attrib3 PI DataReferenece returning a value
Suppose we like to add Attrib1 with Attrib3 in the formula of Attrib2. Then we encounter the problem that the formula returns an error if the webservice returns a string. This as the string can’t be added to a value in the formula.
Now the question is; does anyone have an elegant solution for this problem. The solutions we have so far are:
1) Catch the string in the data reference. We could program that any non string values are converted to 0 or 99999. This is non preferred option as the data reference may pass valid strings in other cases.
2) Unfortunately the formula data reference doesn’t allow for the use of constants in the IF-THEN-ELSE statements. So we have to revert to making an additional attribute for every value we have to check against. E.g. if we want to check against the value “NaN” in the IF-THEN-ELSE, we have to make an additional attribute Attrib4 with the value “NaN”. Now we can substitute the “NaN” in the formula for a value. This should work but is not very elegant.
Any bright ideas?