Skip to Content
avatar image
Former Member

Average of Tags using SAP PCo Query

HI All,

I am using PCo_query and I need to average the tag values for each one hour for a day.

I have given the Duration as 1 hr in Query Template. How can I get the Average for each 1 hr.

Please let me know how to do it?

Regards

G.Partheeban

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 07, 2014 at 02:06 PM

    Hi Partheeban,

    Create a transaction and calculate and provide the start date to the Query from the transaction.

    E.g.:

    You need Average between 7 PM and 8 PM.

    So provide 7 PM as QueryStartDate.

    In PCo Query Object:

    Mode: TagAggregateQuery

    Duration: 1 hour

    Regards,

    Rohit Negi.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 07, 2014 at 02:58 PM

    Hi Partheeban,

    For the PCoQuery, to get a one hour average for each of 24 hours in one day:

    In the Date Range settings: set the Start Date and End Date for a 24 hour period. if you just want the current 24 hour period ending with the current time, leave both empty and set the Duration value to 1 and Duration Units to Days. If you want a weeks worth of data, set Duration value to 7.

    Then sTag Aggregate Query settings, chose the tag(s) to query and check Average from the Aggregates selections. then execute your query and you should get back 24 rows of one hour averages for each day in your date range.

    Regards, Steve

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      After you set a Data Range, set the Interval Count to the number of rows the aggregate returns. For the Duration of 1 Day, setting Interval Count to 24 will return 24 rows of 1 hour Averages.

      You will need to execute multiple queries with different interval counts for the same duration in order to get the results you want. So for a duration of 1 day or 24 hours:

      Interval Count=24 -> 24 1-hour average rows

      Interval Count=4 -> 4 6-hour average rows

      Interval Count=3 -> 3 8-hour average rows

      Interval Count=1 -> 1 24-hour average row.

      In your case, since you are after hourly averages for multiple hours, I would recommend you set your Duration to 24 and then the duration/Interval Count = number of hours in each row returned. For multiple day intervals you will need to adjust the Interval count so that it still returns the number of hours in each interval over the Duration period.

      Regards, Steve