4 Replies Latest reply on Jan 30, 2018 8:05 AM by Roger Palmen

    Daily counter if any input data is available and monthly average

    newfunda

      Hi,

      I need to count the number of days in last month when data was available for any of the 3 input tags (i.e. if input1 > 0 or input2 > 0 or input3 > 0 then count++) then in next month someday I need the average of these 3 inputs which is written back to some PI server.

       

      Please let me know if someone knows how to achieve both daily tasks and related monthly task using PI-AF analysis only.

       

      Thanks,

      Manish

        • Re: Daily counter if any input data is available and monthly average
          sraposo

          Hi Manish,

           

          Do the input need to be greater than 0 for a whole day or only have 1 event that is greater than 0 on a day?

           

          Thanks,

          Sebastien

            • Re: Daily counter if any input data is available and monthly average
              newfunda

              There is no restriction it can be any numeric value for a day.

              Say next day, I am checking for yesterday data then it can be anything i.e. some data or no data, if no data for any input then nothing to be done but if at least one input is having data > 0 then some counter Count = Count + 1 i.e.

              if input1 > 0 or input2 > 0 or input3 > 0 then sum= input1+input2+input3 and Count = Count + 1, meaning I need average in such case daily and then sum up all these daily average to get average for a month (last month).

               

              Also in daily averaging I need to check if input2 > 0.2 then some other counter to count the number of times input2 was greater than 0.2.

               

              I had written the calculation but not sure whether it will work or not. I may need to do more calculation but basically I need monthly report for above scenario.

               

              Calculating daily can be easy but accumulating those daily result for a month and reporting monthly is my goal.

               

              Thanks!

              • Re: Daily counter if any input data is available and monthly average
                newfunda

                Hi Sebastien,

                 

                Whatever I tried is not working, so need your help here. As I said any of the three input value can be either =0 or > 0 for any given day.

                Please find the attachment of the calculation I prepared for the requirement.

                Variables in calculation: NOCD=Number Of Calendar Days

                Step 3 in calculation means go to next day i.e. Day = Day + 1 .

                 

                Kindly let me know in case you need more information.

                 

                Thanks,

                Manish

              • Re: Daily counter if any input data is available and monthly average
                Roger Palmen

                I would do some intermediate calculations:

                • Determine a daily count of the input tags to determine if there is data for these points and store that in a PI Point.
                • Based on the last month you need (previous month, current running month?) use e.g. the average over this tag to determine if there were days with missing data
                • Average can then be calculated using the regular TagAvg function