4 Replies Latest reply on Oct 20, 2016 7:17 PM by tmcmanus

    How to reduce the PI expression length?

    GopinathSridara

      Hi All,

      Below is my query with PI expression and it is throwing error if I increase the number of tags. I want your help in breaking the logic and tags into two sections.

      note: Each tag name is of 50 char's length in the db.

       

      SELECT TOP 1 TIME, CAST(VALUE AS FLOAT32) AS VALUE FROM PIARCHIVE..PICALC

       

      WHERE EXPR = '(if ((''Tag1'' > 2*(Tagspan(''Tag1''))) OR (BadVal(''Tag1''))) then 0 else ''Tag1'')+(if ((''Tag2'' > 2*(Tagspan(''Tag2''))) OR (BadVal(''Tag2''))) then 0 else ''Tag2'')+(if ((''Tag3'' > 2*(Tagspan(''Tag3''))) OR (BadVal(''Tag3''))) then 0 else ''Tag3'')+(if ((''Tag4'' > 2*(Tagspan(''Tag4''))) OR (BadVal(''Tag4''))) then 0 else ''Tag4'')'

       

      AND TIME >= '18-Oct-2015 11:08' AND TIME <= '17-Oct-2016 11:08' AND TIMESTEP = '30m' ORDER BY VALUE DESC

      [PI SDK] PI PE syntax error in Expression. [-12332] Performance Equation: Expression length exceeded the maximum  

       

      I want to break the expression into 2 sections where first section is logic and second is array of tag names to be considered. 

      like - (if ((''Tag1'' > 2*(Tagspan(''Tag1''))) OR (BadVal(''Tag1''))) then 0 else ''Tag1'') apply this logic on (Tag2, tag3, Tag4,,,,,,,,,,,Tag100)

      sample table fyr,

      Tag Name\Time8:00 AM8:30 AM9:00 AM
      Tag1100150125
      Tag2spike20050
      Tag3200bad data30
      Tag4505050
      TOTAL (SUM)350400255

       

      Thanks in Advance.