Hello!

Do anyone know how to get the time and the total time for a tag (string) when it changed?

Value1: 2017-02-21 08:49 (the time when operator started the batch)

Value2: Now() - Value1 (total time since start of batch)

My plan is to show in processbook (realtime) the time and the time elapsed since the batch changed. :-)

//Patrik

Hello Patrik,

There are a lot of ways to accomplish what you like to do. Let's look at the 2 approaches that appear to meet best. The first one is to create a PI Calculation DataSet in PI ProcessBook and the second one would be using Asset Analytics. What both have in common is the PI Expression Syntax. I am using the sample tag BA:ACTIVE.1 for this example and suggest using the PI Performance Equation Reference manual (%pihome%\help\pereference.chm). Alternatively you can use the PE Reference at Live Library.

The calculation approach that I am using is to look backwards in time when the value has changed to the current value and to calculate the time elapsed since then. The first function that appears useful is FindNE

Please check out the parameter description e.g. for the endtime parameter. If the endtime is before the starttime, the function will look backwards in time. Please make sure you chose a period which is not too small depending on how often you expect a change. I have chosen 60 minutes which is already too short considering BA:ACTIVE.1 is not changing very frequent.

An additional input parameter is the current value which you can get by either using TagVal or by just referencing the PI Point 'BA:ACTIVE.1'. So, let's wrap up the FindGE approach:

Now we want the difference (seconds) between now and the time returned by FindNE

This equation should work as PI Calculation within ProcessBook or within Asset Analytics.