I need to find the first time a value equals a certain value. Can I do it in Datalink? Additional I also want to find the last time a value equals a certain value.

I need to find the first time a value equals a certain value. Can I do it in Datalink? Additional I also want to find the last time a value equals a certain value.

- 1 person found this helpful
For that you will be using the following expressions

FindEQ('tag',StartTime,EndTime,Value)

value is the actual value that you want to find, below is a copy from the "PEReference" help file, you can find it in C:\Program Files\PIPC\HELP

## FindEq

Find the first time, within a range, when a point is equal to a given value.

##### Format

FindEq(tag, starttime, endtime, value)

##### Arguments

*tag*A tagname enclosed in single quotes.

*starttime*Beginning of the time range to search; timestamp or time relative to endtime if endtime is a timestamp.

*endtime*End of the time range to search, timestamp or time (in seconds) relative to starttime if starttime is a timestamp. If endtime is earlier than starttime, the range is searched backwards.

*Value*Must be an integer or real number or digital state (character string), the value to search for.

##### Returns

The timestamp closest to starttime, within the given range, for which the point was equal to the given value.

##### Exceptions

If the point was never equal to the given value,

`FindEq`

returns an error value.##### Usage Note

FindEq interpolates between archive events, if necessary, to find the value it is looking for.

##### Examples

FindEq('tag1', 't', '*',40.0) FindEq('digitaltag', '-1d', '*', TagVal('digitaltag', '14-Dec-97')) FindEq('digitaltag', '14-Dec-97', '*', "On")

A number of ways to do this. I would recommend using the DataLink function

**Archive Value**, and then clicking the expression radio button. Henlo de Waal, provided the expression you can enter in the expression box. By switching around the start time and end time you can find the first or last value within the time range. You might want to consult this video to get started: OSIsoft: Get historical PI Data with the PI Archive Value function (PI DL 2013 Excel Add-in) - YouTube..

A number of ways to do this. I would recommend using the DataLink function

Archive Value, and then clicking the expression radio button. Henlo de Waal, provided the expression you can enter in the expression box. By switching around the start time and end time you can find the first or last value within the time range. You might want to consult this video to get started: OSIsoft: Get historical PI Data with the PI Archive Value function (PI DL 2013 Excel Add-in) - YouTube..