Hello All, is there a way to create a tag to fetch Month to date (MTD) and Year to date (YTD) data from PI?
You can use an expression AF analysis to do aggregate MTD and YTD calculations. For instance, for a tag average MTD and YTD calculation for the attribute 'sinusoid', your analysis expressions might look like the following:
The Bom() expression returns the beginning of the month, and using the datetime '1-1' returns January 1st of the current year at midnight. It is also possible to do this using performance equations or totalizer tags, but AF analyses would be recommended over these approaches.
Thanks for your response. How can I apply this to 3 or more PI Points ?
Will this work for 3 tags below:
You will need three different expressions: TagAvg('Sinusoid', '1-1', '*') + TagAvg('SinusoidU', '1-1', '*'') + ....
If you are using analytics, you can use a rollup and this will allow you to dynamically add additional sums without modifying the logic. Note, YTD and MTD expressions can involve a lot of data and I would think about how often they really need to trigger.
No, this will not work. We do have online Help for the PE functions. It may benefit you if you can become familiar with it.
Here is the help for the TagAvg function. The first line states: Find the time-weighted average value of a point over a given time, according to values stored in the PI Archive. Both the phrase "of a point" as well as the examples shown at the bottom of the page indicate that this function is for ONE tag at time.
There is also the Avg function, which returns the average of multiple arguments.
It is apparent to me that you would require a combination of both of these functions, where you first compute the TagAvg individually for each input tag, and then finally Avg that. Here is an example for Month. I leave it to you as an exercise to do the same for the Year.
Avg( TagAvg('SINUSOID',Bom('*'),'*'), TagAvg('SINUSOID2',Bom('*'),'*'), TagAvg('SINUSOID3',Bom('*'),'*') )
I happen to read your comment when I tried to tell the difference between the "Avg" and "TagAvg" function, not by means of single/multiple tags, but the "time-weighted average".
Frankly it is new to me, but it may be of help when I was stuck by the request as below:
For a certain parameter, an average is performed with the interval of one minute. Nodoubtly, the "Avg" PE function fits here. When a hourly average was asked based on the past 60 minute-average, should I utilize the "TagVal" here?
For a certain parameter, an average is performed with the interval of one minute. Nodoubtly, the "Avg" PE function fits here.
I think you should be using TagAvg here. Avg doesn't have a concept of time. TagAvg('tag','*-1m','*')
When a hourly average was asked based on the past 60 minute-average, should I utilize the "TagVal" here?
You should still use TagAvg here. TagAvg('tag','*-1h','*')
Thanks very much, I got your point. I might need to dig out more.
I made an average calculation on a minute basis within Performance Equation, while the time basis being directed by clock-scheduled PE "sacn calss". Then I'd like to come up with the hourly average, which is exactly what I want. (Since I got hundreds of those hour-average to be calculated, therefore I setup the minute average firstly to save the load at each beginning of a new hour). So, the hour-average is based on minute-average calculated before.
For the minute-average, I'm clear that TagVal be the perfect choice.
For the hour-average, in my case, should I utilize the TagMean or TagVal, or, those two functions would lead to the same result?
Just to be clear, TagMean returns the event-weighted average of the point from starttime to endtime. TagVal finds a point's Archive value at a given time.
So the two functions will most likely not lead to the same result.
The only way it can lead to the same result is if the time series doesn't have any variation at all. i.e. flatline.
Retrieving data ...