IF tagval is NULL Then NULL

Hi,

In PI I have a set of LIMS results that come in every three hours and I want to average these over the 24 hours. When all the tags are in, the Average function (in Analyses) works fine.

If one of the data points is NULL (due to any reason) the value returned by the TagVal expression returns the value prior to the actual one I need.

So, two questions. One, how do I get the value to return a value at an exact time (I have this working in Datalink), if the value is NULL, show NULL, ELSE show value.

 

Second question, can I do an IF((tag) IS NULL THEN NULL ELSE 'tagval','*-6h')). If I put a 0 then the TagAvg is going to be wrong.

 

Many thanks.

Parents
  • A way to potentially make this work is to have an intermediate tag that comes from the expression:

     

    IF((tag) IS NULL THEN Nooutput() ELSE (tag)) -> save as "filtered tag"

     

    Then you can do an event weighted average (not time weighted, as you want just the average of each value, as how long it was that value is irrelevant) on the filtered tag, as it should only get the actual values.

     

    Tagmean("Filtered tag",'*-24h','*')

     

    The drawback is that if you have hundreds or thousand of lab values, you will use up more tags to get this function, but you can build templates this if using AF and roll it out quickly. 

Reply
  • A way to potentially make this work is to have an intermediate tag that comes from the expression:

     

    IF((tag) IS NULL THEN Nooutput() ELSE (tag)) -> save as "filtered tag"

     

    Then you can do an event weighted average (not time weighted, as you want just the average of each value, as how long it was that value is irrelevant) on the filtered tag, as it should only get the actual values.

     

    Tagmean("Filtered tag",'*-24h','*')

     

    The drawback is that if you have hundreds or thousand of lab values, you will use up more tags to get this function, but you can build templates this if using AF and roll it out quickly. 

Children