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. 

  • Hi Jim,

    So, I got this Then NoOutput variable working, but what I ended up doing was an "If Grade5am = Grade2am, then NoOutput() Else Grade5am. This worked and gave me a '-' as a result. However the dash now won't allow me to do an Avg on the values.

     

    I know the solution is not perfect with the two grades, but they have enough trailing digits to make them almost unique over the 3 hour span.

    Any ideas now?

     

    Ray

Reply
  • Hi Jim,

    So, I got this Then NoOutput variable working, but what I ended up doing was an "If Grade5am = Grade2am, then NoOutput() Else Grade5am. This worked and gave me a '-' as a result. However the dash now won't allow me to do an Avg on the values.

     

    I know the solution is not perfect with the two grades, but they have enough trailing digits to make them almost unique over the 3 hour span.

    Any ideas now?

     

    Ray

Children