IMD SolutionComputing LibraryShop main store

Troubleshooting

Why slash aliases in tag historian query return zero rows

Edge computing and IIoT Published 5 min read

Short answer

The script access pattern is correct: getCoreResults() and getRowCount() are the documented calls for reading a Tag Historian Query from a Script data source. The zero row count comes from the query, not the method. Replace every slash in the Data Key Alias with an underscore, leave the historian tag path untouched, and read row zero only after the row count is greater than zero.

On this page
  1. What a zero row count is telling you
  2. Confirm the script access pattern
  3. Rule out the date window and parameter binding first
  4. Example: replacing five slashes in the ITLoad_Start query alias
  5. Rename the alias, never the tag path
  6. Verify the fix end to end
  7. Questions asked

The script is right; the alias is wrong. getCoreResults() is the documented way to pull a Tag Historian Query result into a Script data source, and getRowCount() is the right way to size it. When getRowCount() returns 0 while the historian holds data and the preview table is empty, the query, not the script, produced nothing. In the configuration behind this case, a slash sitting in the Data Key Alias was the cause. Replace every slash with an underscore, keep the historian tag path exactly as the browser generated it, and read the value only after the row count clears zero.

What a zero row count is telling you #

Three observations together place the fault upstream of the script. The script finishing without an exception proves only that the reporting engine built a result object. getCoreResults() returning a dataset proves the wrapper was accessed correctly, not that samples came back. A row count of 0 with an empty preview means the Tag Historian Query returned no rows before your script ever ran, so getValueAt(0, ...) has nothing to read and no change to row-access code can fix it.

What you see What it means Next check
Script runs without error The access pattern is correct Leave the method calls in place
Preview table is empty The query returned no rows Work on the query configuration
getRowCount() returns 0 The dataset holds no samples Date window, parameter binding, then alias

The failure boundary sits between the query configuration and its result. Treat 0 as a measurement, not a malfunction.

Confirm the script access pattern #

For a data key named ITLoad_Start, the documented pattern reads:

startDs = data['ITLoad_Start'].getCoreResults()
rowCount = startDs.getRowCount()

startDs is the dataset that getCoreResults() extracts from the query object held under the data key, and rowCount is the integer row count of that dataset, which reads 0 in the failing case. The Ignition User Manual documents getCoreResults as the accessor for query results in a Script data source, so the calls stay; the configuration feeding them is what changes.

Rule out the date window and parameter binding first #

Clear the simple causes before touching punctuation, in this order:

  1. Read the evaluated StartDate and EndDate in the preview context; the start must precede the end.
  2. Confirm stored history exists for the selected tag across that interval.
  3. Confirm the query inputs bind to those two parameters, not to unused report values.
  4. Preview again. Rows appearing now ends the investigation; the alias was never at fault.

Zero rows can also mean the historian never stored samples at all, which is a collection-side fault worked through separately in Historian trend empty: PLC tag collection troubleshooting. If every item above passes and the row count still reads 0, punctuation is the remaining suspect.

Example: replacing five slashes in the ITLoad_Start query alias #

The inputs, as the failing case presents them: historian connection IgnitionDB01 on MSSQL; tag path kul12_reporting/dpm/l1/pdu_l1_n1/energy/kwh, dragged unchanged from the historian browser; Tag Historian Query data key ITLoad_Start; Script data source ITLoad_Calculated; Ignition 8.1.25 with Reporting Module 6.1.25. The units in this example are characters and rows.

The rule: a Data Key Alias must contain no slash character. The alias names the result field the report and script see, while the tag path keeps identifying the stored series; the two never need to match.

The arithmetic: the path divides into six segments, kul12_reporting, dpm, l1, pdu_l1_n1, energy and kwh, separated by five slashes, and an alias must hold zero. Five minus zero gives five replacements, one per slash, so the path becomes kul12_reporting_dpm_l1_pdu_l1_n1_energy_kwh. The three underscores already inside kul12_reporting and pdu_l1_n1 predate the rename and stay, so the alias ends with eight underscores in total, five of them new.

The result: with zero slashes in the alias, the query preview returns rows and getRowCount() leaves 0 and reads above 0, which is exactly what this case showed after the rename.

The decision: in this configuration a single slash anywhere in a Data Key Alias is enough to empty the result, so one slash means zero rows. An alias of letters, digits and underscores returns rows. If a slash-free alias still yields 0, the fault is the window or the binding, not punctuation.

Rename the alias, never the tag path #

The Data Key Alias field sits beside each tag path in the query's tag list, and it is the only field you edit. The vendor's training material for this query type describes the alias as the name the tag carries into the design panel, which is why the script addresses the alias rather than the path.

Field Role Action
Tag path Identifies the history series in the historian Keep exactly as dragged from the browser
Data Key Alias Names the result column the report and script see Replace every / with _
getValueAt() column argument Must match the alias string Copy it from the preview header

A slash in a historian identifier failing downstream is not unique to reports; the same character breaks PI-side calculations in Fix PI calculations on slash-containing DeltaV historian tags. Alias handling in this same query type also shifts results in tall format, covered in Tag historian query tall format shows shifted data key aliases.

Verify the fix end to end #

  1. Open the Tag Historian Query behind the ITLoad_Start data key and confirm every alias holds no slash.
  2. Leave the historian connection and the dragged tag paths unchanged.
  3. Re-check the StartDate and EndDate bindings and the stored history inside the window.
  4. Preview the query: rows must appear and the column header must read the underscore alias.
  5. Run the ITLoad_Calculated script data source and confirm getRowCount() returns more than 0.
  6. Read row zero by the alias string and compare it against the preview's first row:
startDs = data['ITLoad_Start'].getCoreResults()
rowCount = startDs.getRowCount()
if rowCount > 0:
    value = startDs.getValueAt(0, 'kul12_reporting_dpm_l1_pdu_l1_n1_energy_kwh')

startDs is the dataset returned by getCoreResults(), rowCount the integer row count, and value the energy sample at row zero. That comparison is the test: if the script's value differs from the preview's first row, the column string does not match the alias the query exposes.

The decisions, by case: a slash in any alias means rename to underscores and expect rows at the next preview. Alias clean and rows still 0 means date window, bindings, then the collection-side checks above. Rows above 0 means read with the row-count guard, addressing the column by the alias string exactly as the preview spells it.

Questions asked

Is getCoreResults() the right method for a Tag Historian Query in a Script data source?

Yes. The vendor's user manual for query-based scripting data sources documents getCoreResults as the accessor for a query's results, and getRowCount counts the rows in the dataset it returns. A count of zero means the query produced no rows; check the date window, the parameter bindings and the Data Key Alias before changing the method calls.

Should the historian tag path be renamed to match the new alias?

No. The tag path identifies the stored history series and stays exactly as the historian browser generated it. Only the Data Key Alias changes, because it names the column the report and the script see. Renaming live tag paths to suit one report can break every other consumer of those paths.

What string goes into getValueAt() after the rename?

The exact Data Key Alias as the query preview displays it. For the path kul12_reporting/dpm/l1/pdu_l1_n1/energy/kwh the matching alias is kul12_reporting_dpm_l1_pdu_l1_n1_energy_kwh. Pass the alias string as the column argument; a name-based lookup keeps the script independent of column order and fails loudly instead of reading the wrong field.

The preview now shows rows but the script still returns nothing, so what comes next?

Confirm the script reads the query object by its exact data key, calls getCoreResults and getRowCount, guards the read with a row count above zero, and passes the alias string shown in the preview. As a final check, compare the value read at row zero with row zero of the preview table; a mismatch means the column string differs from the alias.

Keep reading

  • Troubleshooting

    Tag historian query tall format shows shifted data key aliases

    When a report's tag historian query runs in tall format and a data key shows t_stamp where a tag alias belongs, the query's returned key list is offset against the configured aliases, not the stored data. Compare returned keys to configured tag paths first, then fix the report binding or script an explicit key-to-tag mapping.

    Edge computing and IIoT

  • Troubleshooting

    Historian trend flat line: check Query Row Limit

    A historian trend that draws one straight value in history mode while live mode and a direct SQL query both return good data is truncating rows client-side. The tag's Query Row Limit on the graph was set to 2 instead of the documented default 0, so only two samples came back. Set it to 0, then confirm the trend's saved row count matches the SQL count.

    Edge computing and IIoT

  • Troubleshooting

    Citect Historian 2016 slow retrieval as SQL tables grow

    Retrieval slow in both the Citect Historian Excel tool and a direct SQL query is a response-time problem in the SQL history tables, which grow with every historized row. Lower over-fast storage rates, purge to your retention, reindex, and start the migration to AVEVA Historian, since end of support for Citect Historian has been announced.

    Edge computing and IIoT

Why only Historian Trend follows a redundant partner