IMD SolutionComputing LibraryShop main store

Troubleshooting

Why a bad quality update hides Historian values

Edge computing and IIoT Published 6 min read

Short answer

An update that marks a sample bad makes the historian store that row with a NULL value, so the number is gone in place and no retrieval mode brings it back. Insert a replacement row carrying the old value at OPCQuality 64 — uncertain — which stays stored, retrievable and distinguishable from good data. Set OPCQuality, not QualityDetail.

On this page
  1. Why did the values disappear after the quality update?
  2. Which quality field do you set, OPCQuality or QualityDetail?
  3. What quality code keeps the value visible but not good?
  4. How do you insert a replacement row with uncertain quality?
  5. Why does HistorianClient still hide the row under a Good Quality filter?
  6. Do QualityRules or the Historian version change any of this?
  7. How do you verify the value is back for the operators?
  8. Questions asked

An update that sets a sample to bad quality also destroys its number: AVEVA Historian stores a bad-quality row with a NULL value, so after the change no query, retrieval mode or QualityRule returns the measurement. The decision when you want a value hidden but kept: insert a replacement row carrying the old value at OPCQuality 64, uncertain. The value stays stored, stays queryable and stays distinguishable from good samples at 192. Set OPCQuality — the externally reported quality — never QualityDetail, the historian's internal status field.

Why did the values disappear after the quality update? #

Because the historian stores a bad-quality sample with a NULL value: the moment your update set quality to bad, the stored number was discarded, and no query or quality rule can read it back from that row.

The OPC DA quality model allows a bad sample to carry a value; this historian does not keep one, so the loss is in storage, not in the query. That is why the verification step after the UPDATE returned nothing — QualityDetail read 0, and there was no value left to return.

Separate the three ways a number can go missing before you touch anything:

Which quality field do you set, OPCQuality or QualityDetail? #

Set OPCQuality: it is the externally reported data quality that clients and filters evaluate, while QualityDetail is the historian's internal status field, and zeroing it did not restore values in the tested updates.

The two fields often hold matching values, but they answer different questions. OPCQuality is what any client, filter or downstream system sees; QualityDetail is the historian's own status for the row. The tested UPDATE path lowered QualityDetail to 0 and left the values unretrievable — an internal status change is not a substitute for assigning external quality.

Field What it is What you do with it
OPCQuality Externally reported data quality Set it: 192 good, 64 uncertain, 0 bad
QualityDetail Internal historian status Read it for diagnostics; never use it to classify a sample for clients

What quality code keeps the value visible but not good? #

OPCQuality 64, uncertain: the value stays stored and retrievable and remains distinguishable from good samples at 192, while OPCQuality 0 is bad and always stores NULL in this historian.

OPCQuality Hex OPC DA meaning Value in storage
192 0xC0 good kept
64 0x40 uncertain kept, distinguishable from good
0 0x00 bad NULL

Worked example (illustrative counts, not a measured result): a test tag writes one sample a minute, and the window 09:00:00 to 09:09:00 holds 10 rows, all OPCQuality 192. An UPDATE sets 3 of them to bad quality.

  • Rows in the window: 10
  • Rows now stored with Value = NULL: 3
  • Rows a Good Quality filter still shows: 10 − 3 = 7

The 3 numbers are gone. Had you written replacement rows as the latest version at each timestamp instead, the same window would read 7 good rows plus 3 uncertain rows — 7 + 3 = 10 rows with stored values. That is exactly the original goal: 64 keeps a sample out of Good-filtered views while leaving it queryable, while 0 removes it from every view by destroying the value.

How do you insert a replacement row with uncertain quality? #

Copy the value and timestamp from the surviving source row into a new History row with OPCQuality 64 and wwVersion 'LATEST' — the INSERT creates a retrievable entry; it does not repair the NULL row in place.

Two patterns from the working tests; the tag names and bounds are examples, so replace them with your target. The first stamps one timestamp:

USE Runtime
INSERT History (TagName, DateTime, Value, wwVersion, OPCQuality)
SELECT TagName, '2024-08-16 09:00:00', Value, 'LATEST', 64
FROM History
WHERE TagName = 'test_sqlinsert_0824'
  AND wwRetrievalMode = 'FULL'

The second rewrites a bounded range, carrying each row's own timestamp:

USE Runtime
INSERT History (TagName, OPCQuality, Value, DateTime, wwVersion)
SELECT TagName, 64, Value, DateTime, 'LATEST'
FROM History
WHERE TagName = 'test'
  AND DateTime >= '20000101 00:00:00.000'
  AND DateTime < '20000201 12:00:00.000'
  AND wwRetrievalMode = 'FULL'

Write both time bounds in the same yyyyMMdd hh:mm:ss.mmm form before you run anything. Then work the statement in this order:

  1. Retrieve the window with wwRetrievalMode = 'FULL' and list which rows still carry values.
  2. Run the INSERT ... SELECT on one bounded tag and confirm the inserted row count matches your selection.
  3. Retrieve again and check that Value is non-NULL and OPCQuality reads 64.

Run it on a single test tag first: rows written into History become stored data, and a later quality change cannot undo an insert that hit the wrong range.

Why does HistorianClient still hide the row under a Good Quality filter? #

Because the filter is doing its job: with Good Quality selected, HistorianClient excludes OPCQuality 64 by design, so an uncertain row that verifies in SQL disappears the moment the operator's filter is applied.

Retrieval is a chain: the query applies the requested quality rule, then HistorianClient applies the view's filter, then the display draws what survived both. A row that verifies in an unfiltered query and vanishes under the operator's filter is a filter result, not a storage loss — compare the filter's quality class with the row's OPCQuality before concluding the insert failed. A trend that flatlines or thins as the range grows is not quality at all: that is the case behind historian trend flat line: check Query Row Limit.

Do QualityRules or the Historian version change any of this? #

No: the tested QualityRules 'Extended' and 'Optimistic' returned no values after the update, and the behavior was identical on Historian 20.1.100.000 and 17.3.000.000, so neither a rule change nor a version move recovers the number.

Quality rules change how retrieval interprets stored rows; they do not put a number back into a row stored as NULL. The same result on both release lines means the recovery path is the insert, not a settings change or an upgrade.

How do you verify the value is back for the operators? #

Retrieve the bounded interval with no quality filter and confirm three things on the inserted row — the timestamp, a non-NULL Value and OPCQuality 64 — then repeat the retrieval through the operator's exact filter.

  • Unfiltered retrieval: the inserted row's timestamp matches, Value is non-NULL, OPCQuality reads 64.
  • Do not treat QualityDetail as proof of external quality; it is the internal status.
  • Filtered retrieval: the row appears only where that filter admits uncertain quality.
  • Trend check: the value draws at the sample times in the window the operators actually use.

The standing decisions: hide a value while keeping it retrievable — insert with OPCQuality 64; declare a value invalid and accept the NULL — bad quality, 0; either way, the field you set is OPCQuality.

Questions asked

Can the original value be recovered once a row was updated to bad quality?

Not from that row. The update replaced the stored value with NULL, and no retrieval mode or QualityRule reconstructs it. Recover the number from an authoritative copy — the source system, a store-and-forward buffer, a replication target or a backup — and insert it as a replacement row with OPCQuality 64.

Why doesn't wwRetrievalMode = 'FULL' bring the value back?

FULL changes how rows are returned, not what is stored. The row's Value was set to NULL when its quality became bad, so there is no number left for any retrieval mode to interpolate or hold. The loss is in storage, which is why the insert, not the query, is the fix.

The statements fail on tag names containing characters like ä or ü. What then?

In the reported tests, neither INSERT nor UPDATE worked on tags whose names contain those characters, so treat them as a separate problem. Match the tag name exactly as the historian stores it, and prove the statement on one such tag before running anything across many tags.

Will operators see the uncertain value in HistorianClient?

Only where their filter admits it. A Good Quality filter hides OPCQuality 64 by design — that is what keeps uncertain data distinguishable from good data at 192. Verify with the exact filter settings the operators use, and expect the row to appear once uncertain quality is included.

Is UPDATE ever the right tool for this?

Not for hiding a value you want to keep. The tested UPDATE changed QualityDetail, the internal status, and left the values unretrievable; the tested INSERT with OPCQuality 64 kept them retrievable. Reserve UPDATE for changes the vendor documents for the specific field you intend to move.

Keep reading

  • Troubleshooting

    Fix historian silent data gaps with a registry value

    The data is stored; the retrieval view of it is stale. On the Historian server, create the DWORD32 value UseFileCacheForRetrieval set to 0 under HKLM\SOFTWARE\ArchestrA\Historian\Programs\aahStorage, then refresh the trend, with no reboot required. Confirm the fix by loading a previously blank window before running any manual query.

    Edge computing and IIoT

  • Troubleshooting

    Plant SCADA Connector shows connected but historian tags are NULL

    Connected status on both Connector ends proves the connections, not the reads: with Citect error 29, Bad User Parameters, the driver subsystem rejects the read before any value exists to store. Check the I/O Device special options and the variable tag data types first and leave the historian destination alone.

    Edge computing and IIoT

  • Troubleshooting

    Why PI shows live values but no trend history

    A moving live value with an empty trend means the Snapshot is healthy and the archive write path is not. Sample piartool -qs twice a few minutes apart: if Total Event Reads climbs while Total Event Writes stays fixed, check free space on the archive and queue volumes, then piartool -al for an online writable primary archive, and stop at suspected corruption with the outputs in hand.

    Edge computing and IIoT