2 of 2 people found this helpful
((This sadly won't be an easy solution, but it is the only that that I came up that didn't involve writing a small external script))
((This also requires a PSA license as it involves using PI OLEDB Provider)
I am assuming that you already have a analysis that takes care of marking which days should be used and which days shouldn't be used and that this result is stored in a tag. (Such data could be created using the analysis service and the TIMEEQ method). I will just call this attribute called 'ShouldIUse' and its values will change between true and false.
It is possible to create filtered summaries on the condition 'shouldIUse' = True as described from page 32 of the Ales' excellent guide: Tips and Tricks for Asset Based Analytics
The difficulty is of then getting the start time for such a filtered summary.
I can imagine two ways to do this. One using PI OLEDB Provider (which would require a PSA license) and pure analysis.
As the method FindEq only returns the last value, you need to start applying it multiple times to get earlier and earlier days.
Where the values look as follows:
Using PI OLEDB:
To do so, we can use the PI OLEDB Provider to expose PI Data as an AF Table in AF. You can build such a table connection by choosing "PI OLE DB Provider" when you build a connection.
As the tag stores one value per day and it is either true or false, it is then easy to query it to get 30 values of true and then pick the time stamp of the earliest result.
For example, this will give you such a timestamp.
select top 1 time
(SELECT top 30 tag, time, value
WHERE tag = 'Once a day1.Output.d560fbdf-55bc-5b32-1578-dd2cba08f966'
AND time BETWEEN '*-100d' AND '*'
and value = 'ON' order by time) lastthirty
Sadly complicated, but haven't found a way to simplify this yet.
Yes this work. But, for this use case, we wants to retrieve the timestamp of the 30th latest event which has a certain value. Sadly, it does not seem to be easy to get such a value currently.
1 of 1 people found this helpful
That will get the first day the boiler was operational from 200 days ago forward. Not the 30th day back.
I would extend the analysis to add this information to some helper PI Points: store the 30th-day back in a Datetime attribute. When a new operational day has closed, find the next day looking forward from that datetime using FindEQ.
I just wanted to say thank you, Jerome. Your answer is very helpful.
I also opened a tech support case at the same time as posting the question to PI Square. Yvonne Radsmikham provided another possible solution that I wanted to share. She suggested using Totalizer points to sum up the 30 days.
The calculation that you are attempting may not be entirely possible (or very effective) using PI Analysis Service alone. Here’s what I recommend:
1. Use PI Analysis Service to write to a new tag when the condition for the unit load is greater than zero for the entire day. When this condition is met, have PI Analysis Service write the daily average value to the new tag. If the condition is not met, have nothing be written.
2. Use Totalizer to determine the 30-day Moving Time- Weighted Average. This can be done using SMT > Points > Totalizer. See below for the possible tag configuration for the Totalizer tag.
Instead of having Totalizer account for the last 30 consecutive days, you can ask that it use the last 30 events of the new tag written by the PI Analysis Service, which should essentially be the last 30 “Boiling Operating Days”.
I like Jerome's response as it would allow me to do everything in Analysis, but using the totalizer is something that I had not considered, and is very clever.