YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Max Value Per Hour Options · View
JamieMcc
#1 Posted : Friday, March 25, 2011 7:23:36 AM
Rank: Newbie
Groups: Member

Joined: 9/21/2010
Posts: 3
Location: Vancouver
Hi there,

I have had a request from a customer to extract some data for the past year. What they would like is to have a data dump where they could see the Maximum value of an analog tag for each hour for the last year.

To clarify, 1 value per hour - which is the maximum value for that hour and the report would have 24 x 365 rows.

Can someone help me write this query? I am assuming that I need to do an aggregate query (max) grouping by the hour for each day, but honestly not sure how to write it.

Thanks in advance,

Jamie
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
Burnikell1
#2 Posted : Friday, March 25, 2011 11:33:48 AM
Rank: Advanced Member
Groups: Member

Joined: 7/23/2008
Posts: 38
Location: Cheshire, UK
Hi Jamie,


Quick solution to this is to use the DataLink Calculated Data option

Select your tag

Start Time as * for example with end time of *-1 year

Interval Period = 1 hr

Calculation Mode as maximum

This will bring the hourly maximum values for every day of the year i.e. 8760 values.

Its just a matter then of formatting the spreadsheet to look nice.

Alternatively you could do something with performance equations using the TagMax function, although i'd ned to look at this a bit more. As i said the quickest, easiest and lack of needing to program anything method is datalink.

Regards,



milesUK
#3 Posted : Monday, March 28, 2011 9:08:18 AM
Rank: Advanced Member
Groups: Member

Joined: 5/28/2009
Posts: 75
Location: Cheshire, UK
I agree with Burnikell1 that for a one off task that would be my approach. Except that I would not use * as this could provide misleading (and possibly different) data depending on what time you recalculated the sheet.

A method:

Place the tag in A1

In the first column (A2 downwards) populate the days.

In the row for your first day select all 24 cells to hold the data (B2:Y2) and build this Calculated Data formula:

=PICalcDat($A$1,$A2,$A2+1,"1 hour","maximum",1,2,"prepidata")

This will make 365 calls to PI for the data which will be slower than Burnikell1's suggestion of grabbing all 8k values in one go. Our PI 2 system returned the data for one tag in 50 seconds.

Once you have that cracked you can do max/min as well and impress your customer. BigGrin
MilesUK
ProcessBook v3.0.15.3
ejyoungone
#4 Posted : Tuesday, March 29, 2011 4:06:31 PM
Rank: Member
Groups: Member

Joined: 11/30/2010
Posts: 15
Location: New York, USA
Dim TagVal As PISDK.PIValue
Set TagVal = PiPt.Data.Summary(StartTime, EndTime, astMaximum, cbEventWeightedExcludeMostRecentEvent)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.