4 Replies Latest reply on Jun 1, 2015 8:32 PM by asorokina

    Average calcualtion PI ACE


      I am trying to calculate the average value of a tag for a single day's data. Here is the code snippet:



      Output_Tag.Value = Input_Tag_1.Avg((Today.AddDays(-1)), Today, 80) + Input_Tag_2.Avg((Today.AddDays(-1)), Today, 80)


      I want to calculate the average between yesterday 12AM to today 12AM. The issue I am facing in this calculation is if any data is present for any day it is returning the average value irrespective of the range specified. I have tested it by deleting yesterday's data but still it is showing the average value calculating the average of 27th April's data.

      Can any help with this?

        • Re: Average calcualtion PI ACE

          I would try writing your formula using the pi time format where "y" is yesterday at midnight and "t" is today at midnight and see if that makes a difference.


          So for example: Output_Tag.Value = Input_Tag_1.Avg("y", "t", 80) + Input_Tag_2.Avg("y", "t", 80)

            • Re: Average calcualtion PI ACE

              I tried this too but still it is taking the old day's values. There are no values in the mentioned timestamps but still it is taking the old day's data and calculating the average

                • Re: Average calcualtion PI ACE

                  Hi Vaishali,


                  Please allow us to get some more information in order to assist you:

                  • What version of PI ACE are you running? There is a known issue 24267OSI8 relating to incorrect timestamps, though the issue is resolved in the latest version.
                  • Do you see the same results when you are debugging or testing the calculation? Or do you see the results in your output tag? If haven't done so, can you tried debugging and testing the application using the ACE wizard and see if you also get the wrong values?
                  • If the issue is only happening when the calculation is running by the scheduler, try including code to output to the ACE logs, turning on debugging and observing the PI message logs to see if we get additional information.
              • Re: Average calcualtion PI ACE

                Hi Vaishali,


                We noticed that this issue was resolved by our Tech Support team in case # 626641.

                Quoting the resolution entry:

                Performed recalculation and then we see different output values are inserted into the output tag. Hence, it verified that the "y" and "t" are working for recalculation.

                Thanks to the TSE, Wilson Teo!