please help for AF formula
if('TAG.ALM' <> "NR" ) then 1 else if('TAG.PV' =2) then 2 else IF('TAG.PV'= 0) THEN 3 ELSE NOOUTPUT()
i have created all attributes like TAG.ALM, TAG.PV
all tags are also created in pi smt
Formulas do not support strings. If you want to work with strings, then an Analysis would be required.
Could you please provide some more details on what's going on? From a simple procedural standpoint, you have correctly written your nested if's. Are you getting an error or an unexpected result?
hi Rafael Borges,
thanks for your attention
our Formula: A=ALM ;B=PV;[if(A <> NR) then 1 else if(B = 2) then 2 else if(B = 0) then 3 else -99]
we got the error "Parameter 'NR' is uninitialized in expression'if(A<>NR) then 1 else if(B=2) then 2 else if (B=0) then 3 else -99"
please check the error in following image
In your question you have -- ('TAG.ALM' <> "NR" . This is correct if NR is a string constant. However, in your screenshot, the quotation marks are missing, so it thinks NR is a variable in your formula. You need to put back the quotation marks.
Hi Patrick Crummie,
thanks for your suggestion
i have created it by single (‘ ’) or double (“ ”) quotation marks then also it shows error for that quotation marks.
it not allows me to put "NR" as a string constant.
I am sorry. You are absolutely correct. There seems to be something very wrong here (a bug?). I would suggest that you do this as an analysis rather than a formula. Are you familiar with setting up AF Analyses?
Interesting to see we all overlooked the obvious...
In case anyone is interested, the documentation confirms that strings are not supported: https://livelibrary.osisoft.com/LiveLibrary/content/en/server-v7/GUID-7BD83062-02CD-4858-8A6E-04F53C419661.
And another major one:
Use == for comparisons: A == "NR"
If you use = that is an assignment, e.g. "A = NR" assigns the value of the variable NR to variable A. Hence the error value.
Note that you also use an assignment in B=2, so the expression If(B=2) is not zero, so will always return 2 even when B is not 2.
Documentation here: https://livelibrary.osisoft.com/LiveLibrary/content/en/server-v8/GUID-F9A37844-F1A3-4D04-A723-0FEC622CF65B
Retrieving data ...