cancel
Showing results for 
Search instead for 
Did you mean: 

Average or AverageTW - PCO Aggregate Query ?

0 Kudos

Hi Experts,

I am querying iHistorian database from MII 12.2 using PCO Tag query.

I want to get the average value of a Tag for previous day.

Let assume, I want to take average of speed tag or previous day. Please do let me know which aggregate function need to be used - Average or AverageTW ??

What is the mean of AverageTW function ?? also how can i set time for the same to get previous day average value !

Regards,

Gaurang

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Gaurang,

Concept of Average is quite simple. Average TW or TWA (Time weighted average) is calculated by taking into account the time for which the tag was having a particular average value in a given time duration.

e.g. Tag1's average value for first 15 min was x then may be for other 1 hr it was y, so hence and so forth.

So, depending on your requirement you may use either of the method.

In order to set the time duration for previous day, you can use the Start DateTime & End DateTime of the tag query.

Best Regards,

Anuj

0 Kudos

For Historians, you should generally use TWA.  The only time you should use the regular average is if there are data points at consistently regular intervals.  Even then what you get is the same value from Average as you would from TWA. 

Regards, Mike

0 Kudos

Hi Experts ,

Thanks for the solution.

Michael , I am getting output aft 0 value while using Average alone. But i am getting output by using AverageTW.

Anuj, If i will set startdate as yesterday and end date as today and select AverageTW for a particular tag, Then will i get the average value for duration between startdate and enddate ? ? am i correct ??

Because while using Average provided in PCO is giving me 0

Regards,

Gaurang

0 Kudos

Hi Gaurang,

Check the raw data either through History or directly in the historian.  That should give you a clue about what you are seeing.  However, it could also be the way iHistorian is calculating the Average.  That will require some research into both PCo and iHistorian.  If iHistorian has it's own Average and TWA functions those could be simply used by PCo to return the result set.  If iHistorian does not have those functions or PCo is not using them, then you need to determine how PCo does the Average calculation with a set of raw data from iHistorian.  You will also need to see if there is any invalid data within the date range you have specified.  If you want to test, make sure you are not working in a Daylight Savings switch over time frame.  Some historians act a little funky if you are pulling results that include those dates in your ranges.

Cheers, Mike

Former Member
0 Kudos

Hi Gaurang,

If the Average is coming out to be 0 for the time interval you are giving as input, logically TWA will also come as 0 because as I have mentioned in my earlier post that the TWA ultimately checks for the Average of the values by considering the time duration for each different average.

Best Regards,

Anuj

former_member196557
Active Contributor
0 Kudos

Hi Gaurang,

I concur with Mike's comment, retrieive the History for the date range and make sure that there are values for the range, and then execute the Average and Average TW.

You might also want to consider configuring a PCoConnector in Data Servers and using a PCoQuery.  Make sure the PCo Agent Instance set up to listen on separate ports for the two MII versions if you want to use separate Data Servers for each.

Regards, Steve

former_member204240
Active Participant
0 Kudos

If you are writing an TRX in BLS, then you can use Aggregate_Statistics action block under XML functions. which is simple and easy for any calculation of Avg, Min , Max etc.

Warm Regards,

Padma