Hello All, is there a way to create a tag to fetch Month to date (MTD) and Year to date (YTD) data from PI?

Hello All, is there a way to create a tag to fetch Month to date (MTD) and Year to date (YTD) data from PI?

Hello James,

Thanks for your response. How can I apply this to 3 or more PI Points ?

Best Regards

Bill

Will this work for 3 tags below:

Month:

TagAvg('SINUSOID'+'SINUSOID2'+'SINUSOID3',Bom('*'),'*')

Year:

TagAvg('SINUSOID'+'SINUSOID2'+'SINUSOID3','1-1','*')

Best Regards

Bill

- 1 person found this helpful
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.

- 2 people found this helpful
Hi Bill,

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('*'),'*') )**Hi Rick,

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?

Regards, ZYY

- 1 person found this helpful
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','*')

Hi Eugene,

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?

Yours, ZYY

2018.11.20

- 1 person found this helpful
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.

Hi Bill,

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.

Regards,

James