AnsweredAssumed Answered

How to get the 20 last events from an attribute

Question asked by Roger Palmen on Mar 22, 2018
Latest reply on May 29, 2018 by Roger Palmen

Hi All,


I need to solve this using either Analytics or by a call to the PI Web API. I need to retrieve the data from PI (using the PI Web API) for the last 20 Events of an AF attribute, and of course i don't know the timeframe involved. That could be hours, weeks, months.


  • Using Analytics i can only think of 20 nested PrevEvent functions to find the 20th event back from now, and then retrieve all the events from that 20th event back. The nestig is of course an eyesore.
  • Using PI Web API i could just request the data for e.g. 1 year backward, but limit the result to the last 20 events(using maxCount in this call: Request Rejected ). As i'm not sure how many events this could return, and when the filtering is done, i'm a bit wary that requesting 1 years data for a data-dense point will cause trouble. But on the other hand i also need to support very sparse data that updates only once per month.


Any ideas?