IMD SolutionComputing LibraryShop main store

How-to

Find the timestamp when a historian point equals a value

Edge computing and IIoT Published 6 min read

Short answer

Use PI DataLink's Calculated Data function with a FindEq performance equation: FindEq returns the timestamp closest to the window's start where the point or attribute equals your target value. Enter the integer lab date as the target and a window covering the entry period. Because the PLC copies the whole block in a couple of seconds, pull the associated points over tens of seconds around the returned timestamp.

On this page
  1. Confirm the integer reached the point first
  2. Return the timestamp with Calculated Data and FindEq
  3. Worked example: a lab date entered as 20250314 during a six-hour window
  4. Read the result and pull the surrounding data
  5. When the search returns nothing
  6. Questions asked

Yes — PI DataLink has no single function that takes a value and hands back the time, but the pairing that answers the question is the Calculated Data function evaluating a FindEq performance equation. The PI Server and AF Analytics documentation describes FindEq as returning the timestamp closest to the interval's start when the attribute equals a specified value. Enter the integer lab date as the target, give the search a window that covers the entry period, and the cell returns the event's timestamp. Because the PLC copies the whole block of lab values within a couple of seconds, that timestamp is a sound anchor: retrieve the associated points over tens of seconds around it. The one trap is breadth — operators who enter several days at once put several candidate integers in one window, and FindEq answers with the match closest to the window's start.

Confirm the integer reached the point first #

The search can only return a time for a value the archive holds, so verify the chain before touching any formula. Read the operator's entry field, read the controller tag after the transfer, and read one archived value from the historian point inside the entry period. Three outcomes tell you where you stand:

  • Entry, controller tag, and point history all carry the integer: proceed to the search.
  • The controller tag is right but the point never recorded the integer: a collection or point-binding fault. Fix the write path; no query can return a timestamp for a value that was never stored.
  • The point holds a formatted date string instead of the integer: equality never matches across that type boundary. Match the search target to the stored form before blaming the formula.

Also confirm you selected the point you think you selected; a look-alike tag returns plausible-looking wrong times.

Return the timestamp with Calculated Data and FindEq #

  1. Open the Calculated Data function in PI DataLink — the function that normally returns evenly spaced calculated values from a PI point or an AF attribute. Its expression input accepts performance equation syntax, and that is where the search lives.
  2. Build the expression around FindEq. Give it the point or attribute, the window's start and end, and the target value; the function returns the time of the equality match closest to the window's start. Enter the parameters by role and check their order in the documentation for your installed DataLink version instead of copying an unverified formula.
  3. Make the cell receive a time. The expression's result is a timestamp, so format the result cell as a date-time; a bare serial number in a regulatory report invites hand edits.
  4. Set the window: begin it just before the entry period and end it just after the last plausible entry. Every second of breadth adds candidate matches.
  5. Read one timestamp per call. If several days went in during one sitting, run one call per day value with a window that contains only that entry, or advance the window's start past each returned hit and search again.

Worked example: a lab date entered as 20250314 during a six-hour window #

Inputs, and where each comes from:

  • Target value: 20250314, the integer the operator entered as this batch's lab date, in a YYYYMMDD-style encoding (example encoding for the case's integer date point).
  • Search window: 06:00 to 12:00 on the morning the technicians back-entered several days of results — an example entry period of the kind the case describes.
  • Copy behavior: the PLC moves the whole block within a couple of seconds (given in the case).
  • Retrieval margin: 15 s on each side of the anchor, chosen so the window is comfortably wider than the copy.

Rule in words: FindEq returns the timestamp closest to the window's start where the point equals 20250314, and the associated points are retrieved over a window centered on that timestamp that is wider than the PLC copy time.

Arithmetic:

  • Search window length: 12:00 - 06:00 = 6 h = 21,600 s.
  • FindEq returns, for illustration, 08:42:17 as the anchor.
  • Retrieval window: 08:42:17 - 15 s = 08:42:02 and 08:42:17 + 15 s = 08:42:32, a 30 s window.
  • Margin: 15 s ÷ 2 s ≈ 7.5 times the couple-of-seconds copy, so the whole block lands inside the window even with transfer jitter.

Result: one anchor timestamp (08:42:17 here) and a 30 s window for pulling the associated points.

Decision: a retrieval window several times wider than the PLC copy captures the block — at this transfer speed 15 s per side is ample, and the margin scales with whatever the next write path measures. Because a six-hour window can hold several day-integers when the technicians enter several days at once, one FindEq call per day value beats one broad call: the broad call returns only the match nearest the window's start.

Read the result and pull the surrounding data #

Search result What it means Next move
No timestamp the integer is not in the point within the window, or the window misses the entry inspect point history around the entry period; widen only enough to include the event
One timestamp the event anchor pull the associated points over the window centered on it
A timestamp for the wrong day several equal integers sat in the window; the call returned the match nearest its start one call per day value, or restart past each returned hit

Pull the associated points with the archived or sampled data functions over that window. Treat the anchor as the center of the window, not as one shared write instant: each point in the copied block keeps its own archive time, and the gap between when a value was written and when the server received it is its own failure mode — the distinction is walked through in why a PI value timestamp is not a receipt time.

The same anchor-then-window discipline answers the sibling question of the timestamp of a max value in a historian report query: narrow window, verified value, one returned time.

When the search returns nothing #

Work down the chain before touching the formula:

  • Integer absent from the point's history: a collection or point-binding fault — repair the write path first.
  • Integer present, search still empty: the target's type does not match the stored form, or the window misses the entry period.
  • A timestamp at an implausible moment: a second identical integer sat in the window and the call handed back the match nearest its start. Narrow the window and rerun.
  • The right event but wrong surrounding data: the associated points were queried at the anchor instant instead of over a window. Re-pull over the window.

Test on a known entry with exactly one expected match before trusting the report, then on a sitting where several days went in together. For a regulatory report, let the workbook compute and format every timestamp — a hand-typed time is the kind of edit an auditor finds and cannot reproduce.

Decision: if the integer is in the point's history, Calculated Data with FindEq returns the anchor and a window wider than the copy returns the block; if the integer never reached the point, fix collection first, and record the point, the target value, and the window in the workbook so the next person reproduces the lookup instead of rebuilding it.

Questions asked

FindEq returned the first match — how do I get the second one?

One call returns one timestamp: the equality match closest to the window's start. To reach a later occurrence, set the window's start a moment after the returned timestamp and run the search again, repeating until no match comes back. For the lab-report case this is rarely needed — one call per day value, each with a window containing only that entry, returns every event exactly once.

Can the search run somewhere other than a spreadsheet formula?

Yes. FindEq is documented as an AF analytics function as well as PI performance equation syntax, so the search can live on the server and hand one anchor timestamp to every client. The workbook then keeps to plain retrievals of the associated points, and every reader of the report gets the same event time.

What if the date point stores text instead of a number?

Equality matches only what the point actually stores. If the archive holds a formatted date string, a numeric target such as 20250314 never equals it, and the search returns nothing even though the value is visibly there. Read one archived value, match the target to that stored form, and rerun before blaming the formula or the collection path.

Why does the returned timestamp sit hours away from the lab log?

The anchor comes back in the archive's server time as the workbook renders it, not necessarily in the clock the lab used. A whole-hour gap between the timestamp and the paper log is almost always a UTC offset question rather than a search fault; settle the report's timezone handling first, then re-read the anchor.

Keep reading

  • How-to

    Get the timestamp of a max value in a historian report query

    A tag history aggregation returns the maximum value alone and drops the row that set it, so there is no timestamp to bind. Add a Script data source below the Tag Historian Query, scan the returned rows with a strict greater-than comparison that carries each row's t_stamp, and bind the report to that pair; or query the history partitions directly with the tie rule written into the SQL.

    Edge computing and IIoT

  • Explainer

    Historian data retrieval speed: what actually decides it

    An indexed historian returns a year-old sample about as fast as yesterday's, so data age is the wrong variable to optimize. Retrieval speed is set by the requested window, returned point count, retrieval mode, archive storage tier and client rendering. Benchmark candidates with identical query semantics before choosing one.

    Edge computing and IIoT

  • Troubleshooting

    Fix a DeltaV embedded trend that shows no PI history

    The error names the chart's own PI history connection, PI1, failing to open — the data is not missing. Process History View working on the same workstation proves the server, network and stored interval are good, so stop cycling hostname, IP and defaulthost and reconcile the chart's Historical Data Server entry and the PI1 connection definition against the viewer's working path.

    Edge computing and IIoT