ihTrend Table
The ihTrend table allows you to compare multiple tags for the same timestamp. It contains a row of data for each unique timestamp, but with columns from one or more tags. The column names are dynamic and determined by the returned tag names. The ihTrend table is similar to a pivot table or, for instance, a cross-tab report that you can create in Crystal Reports.
The ihTrend table can store up to 100 columns in a returned set. This allows you to compare Value
columns with up to 99 tags for a single timestamp, or Value
and Quality
columns with up to 49 tags.
The following table describes the columns of the ihTrend table, including all possible tag columns. Different queries on this table can produce different column results.
Column Name | Data Type | Description |
---|---|---|
TimeStamp | VT_DBTimeStamp | The date and time that the trend was generated. |
TimeStampSeconds | VT_DBTimeStamp | The date and time for the data sample. |
Microseconds | VT_I4 | The microsecond interval for the data sample. |
SamplingMode | VT_BSTR | The mode of sampling data from the archive:
|
Direction | VT_BSTR | The direction (forward or backward from the start time) of data sampling from the archive. |
NumberOfSamples | VT_I4 | Number of samples to retrieve from the archive. Samples will be evenly spaced within the start and end times defined for most sampling modes. For the Note: The NumberofSamples and IntervalMilliseconds columns are mutually exclusive. If NumberofSamples is used, IntervalMilliseconds is not used. |
IntervalMilliseconds | VT_I4 | For non-raw sampled data, this column represents a positive integer for the time interval (in milliseconds) between returned samples. Note: The NumberofSamples and IntervalMilliseconds columns are mutually exclusive. If NumberofSamples is used, IntervalMilliseconds is not used. |
CalculationMode | VT_BSTR | This column applies only if the SamplingMode is set to Calculated . It represents the type of calculation to perform on archive data:
|
FilterTag | VT_BSTR | Tagname used to define the filter, if specified. Only a single tag can be specified. Wildcards are not supported. |
FilterMode | VT_BSTR | The type of time filter:
This value defines how time periods before and after transitions in the filter condition should be handled. For example,AfterTime indicates that the filter condition should be True starting at the timestamp of the archive value that triggered the True condition and ending at the timestamp of the archive value that triggered the False condition. |
FilterComparisonMode | VT_BSTR | The type of comparison to be made on the filter comparison value:
FilterTag value should be compared to the FilterValue value to establish the state of the filter condition. If FilterTag and FilterComparisonValue values are specified, time periods are filtered from the results where the filter condition is False . |
FilterValue | VT_BSTR | The value with which to compare the FilterTag value to determine appropriate filter times. |
FilterExpression | VT_BSTR | An expression which includes one or more filter conditions. The type of conditions used are:
FilterTag , FilterComparisonMode , and FilterValue columns. While using FilterExpression , the expression is passed within single quotes. For complex expressions, you write the conditions within parentheses. There is no maximum length for FilterExpression , but if called using OLE DB or Excel, these tools may have their own limitations. |
TimeZone | VT_BSTR | The type of time zone used:
|
DaylightSavingTime | VT_BOOL | Indicates whether Daylight Saving Time logic should be applied to timestamps. |
RowCount | VT_I4 | Indicates the maximum number of rows that can be returned. A value of 0 indicates that there is no limit to the number of rows returned. |
TagID.Value | VT_VARIANT | The value of the data for the specified tag ID. |
TagID.Quality | VT_VARIANT | For non-raw sampled data, this column displays the percentage of good quality samples in the interval. For instance, a value of 100 means all samples in the interval are good.For raw sampled data, data values are:
|
TagID.Tagname | VT_BSTR | Tagname property of the specified tag ID. |
TagID.Description | VT_BSTR | User description for the specified tag ID. |
TagID.EngUnits | VT_BSTR | Engineering unit description for the specified tag ID. |
TagID.Comment | VT_BSTR | User comment associated with the specified tag ID. |
TagID.DataType | VT_BSTR | The data type for the specified tag ID:
|
TagID.FixedStringLength | VT_UI1 | This value is 0 unless the data type is FixedString . If the data type is FixedString , this number represents the maximum length of the string value. |
TagID.CollectorName | VT_BSTR | The name of the collector responsible for collecting data for the specified tag ID. |
TagID.SourceAddress | VT_BSTR | The address used to identify the specified tag ID at the data source. For iFIX systems, this is the NTF (Node.Tag.Field ). |
TagID.CollectionType | VT_BSTR | Type of collection used to acquire data for the tag:
Note: Not all collectors support unsolicited collection. |
TagID.CollectionInterval | VT_I4 | The time interval, in milliseconds, between readings of data from this tag. For polled collection, this field represents the time between samples. For unsolicited collection, this field represents the minimum time allowed between samples. |
TagID.CollectionOffset | VT_I4 | The time shift from midnight, in milliseconds, for collection of data from this tag. |
TagID.LoadBalancing | VT_BOOL | Indicates whether the data collector should automatically shift the phase of sampling to distribute the activity of the processor evenly over the polling cycle for the specified tag ID. This is sometimes called phase shifting. |
TagID.TimeStampType | VT_BSTR | The timestamp type applied to data samples at collection time:
|
TagID.HiEngineeringUnits | VT_R8 | The high end of the engineering units range. Used only for scaled data types and input scaled tags. |
TagID.LoEngineeringUnits | VT_R8 | The low end of the engineering units range. Used only for scaled data types and input scaled tags. |
TagID.InputScaling | VT_BOOL | Indicates whether the measurement should be converted to an engineering units value. When set to False , the measurement is interpreted as a raw measurement. When set to |
TagID.HiScale | VT_R8 | The high-end value of the input scaling range used for the tag. |
TagID.LoScale | VT_R8 | The low-end value of the input scaling range used for the tag. |
TagID.CollectorCompression | VT_BOOL | Indicates whether collector compression is enabled for the specified tag ID. Collector compression applies a smoothing filter to incoming data by ignoring incremental changes in values that fall within a deadband centered around the last collected value. The collector passes (to the archiver) any new value that falls outside the deadband and then centers the deadband around the new value. |
TagID.CollectorDeadbandPercentRange | VT_R4 | The current value of the compression deadband. |
TagID.ArchiveCompression | VT_BOOL | Indicates whether archive collector compression is enabled for the tag. |
TagID.ArchiveDeadbandPercentRange | VT_R4 | The current value of the archive compression deadband. |
TagID.CollectorGeneral1 | VT_BSTR | The general (or spare) configuration fields for the specified tag ID. |
TagID.CollectorGeneral2 | VT_BSTR | The general (or spare) configuration fields for the specified tag ID. |
TagID.CollectorGeneral3 | VT_BSTR | The general (or spare) configuration fields for the specified tag ID. |
TagID.CollectorGeneral4 | VT_BSTR | The general (or spare) configuration fields for the specified tag ID. |
TagID.CollectorGeneral5 | VT_BSTR | The general (or spare) configuration fields for the specified tag ID. |
TagID.ReadSecurityGroup | VT_BSTR | The name of the Windows security group that controls the reading of data for the specified tag ID. Refer to "Implementing Historian Security" in the Getting Started with Historian manual for definitions of the various security levels and groups. |
TagID.WriteSecurityGroup | VT_BSTR | The name of the Windows security group that controls the writing of data for the specified tag ID. Refer to "Implementing Historian Security" in the Getting Started with Historian manual for definitions of the various security levels and groups. |
TagID.AdministratorSecurityGroup | VT_BSTR | The name of the Windows security group responsible for controlling configuration changes for the specified tag ID. |
TagID.Calculation | VT_BSTR | The equation for the calculation performed for the specified tag ID. |
TagID.LastModified | VT_DBTimeStamp | The date and time that the tag configuration was last modified. The time structure includes milliseconds. |
TagID.LastModifiedUser | VT_BSTR | The username of the Windows user who last modified the tag configuration. |
TagID.CollectorType | VT_BSTR | The type of collector responsible for collecting data for the specified tag ID:
|
TagID.StoreMilliseconds | VT_BOOL | Indicates whether time resolution in milliseconds is enabled for the specified tag ID. If not enabled, time resolution is in seconds instead of milliseconds. Maximum data compression is achieved when this value is set to |
TagID.UTCBias | VT_I4 | The time zone bias for the specified tag ID. Time zone bias is used to indicate the natural time zone of the tag expressed as an offset from UTC (Universal Time Coordinated) in minutes. UTC is the international time standard, the current term for what was commonly referred to as Greenwich Mean Time (GMT). |
TagID.AverageCollectionTime | VT_I4 | The average time it takes to execute the calculation tag since you started the Calculation Collector for the specified tag ID. |
TagID.CollectionDisabled | VT_I4 | Indicates whether collection is enabled (0 ) or disabled (1 ) for the specified tag ID. The default setting is enabled (0 ). |
TagID.CollectorCompressionTimeout | VT_I4 | Indicates the maximum amount of time the collector will wait between sending samples to the archiver. This time is kept per tag, as different tags report to the archiver at different times. This value should be in increments of your collection interval, and not less. Ideally, this field is used for polled data values. It can be used with unsolicited data, but when you do so, you are dependent on the data source for the value to change. With unsolicited data, since Historian only records the value when it changes, the actual time before the timeout might exceed the compression timeout. |
TagID.ArchiveCompressionTimeout | VT_I4 | Indicates the maximum amount of time from the last stored point before another point is stored, if the value does not exceed the archive compression deadband for the specified tag ID. |
TagID.InterfaceAbsoluteDeadbanding | VT_BOOL | Indicates whether absolute collector deadbanding is enabled for the specified tag ID. |
TagID.InterfaceAbsoluteDeadband | VT_R8 | Indicates the value for absolute collector deadbanding. |
TagID.ArchiveAbsoluteDeadbanding | VT_BOOL | Indicates whether absolute archive deadbanding is enabled for the specified tag ID. |
TagID.ArchiveAbsoluteDeadband | VT_R8 | Indicates the value for absolute archive deadbanding. |
TagID.SpikeLogic | VT_BOOL | Indicates whether Spike Logic is enabled on the collector. |
TagID.SpikeLogicOverride | VT_BOOL | Indicates whether the Spike Logic setting for the specified tag ID overrides the collector setting (True ) or the collector setting is used (False ). |
Use care when building queries against the ihTrend table. Because a query to this table compares multiple tags at the same time, it takes longer to query the ihTrend table than it does the ihRawData table. The ihTrend table can be quite large, so be sure to either use the default start and end times, or define a specific time interval. See Query Performance Optimization for more ideas on how to optimize your query of the ihTrend table.
ihTrend Examples
Example SQL statements for the ihTrend table are outlined in the following examples.
Example 1: Retrieve Value and Quality of the First 50 Tags
SELECT timestamp, *.value, *.quality FROM ihtrend
Example 2: Retrieve Value of the First 100 Tags
SELECT timestamp, *.value FROM ihTrend
Example 3: Retrieve Values of All Tags That Match a Specific Pattern
SELECT timestamp,*0001.value FROM ihtrend ORDER BY MY_SERVER.Simulation00001.Value
Example 4: Retrieve Hourly Interpolated Values of TagNames That Match *0001
SET samplingmode=interp, intervalmilliseconds=1h
SELECT timestamp, *0001.value FROM ihtrend
ORDER BY Simulation00001.value DESC, timestamp DESC
Example 5: Retrieve Maximum Values of All TagNames That Match *0001
The following example shows how to use a TagName
(simulation.00001.Value) in a WHERE
clause.
SELECT timestamp, *0001.value FROM ihtrend
WHERE timestamp>='28-nov-2001 00:00'
AND timestamp<='29-nov-2001 00:00:00'
AND samplingmode=calc
AND intervalmilliseconds=1h
AND calculationmode=max
AND simulation00001.Value > 1000 ORDER BY timestamp
Example 6: Select Interpolated Values for All Single Float Tags
The following example shows how to select interpolated values for all single float tags, without doing a JOIN
with the ihTags table to retrieve the DataType
property.
SELECT timestamp, *.value,*.description FROM ihtrend
WHERE timestamp>>='28-nov-2001 00:00'
AND timestamp<='29-nov-2001 00:00:00'
AND samplingmode=calculated
AND intervalmilliseconds=2h
AND *.datatype = singlefloat ORDER BY timestamp
Example 7: Select Interpolated Data for TagNames That Match sim*
The following example shows how to sort the returned rows by a TagName
, simulation.00001.Value.
SET starttime='28-nov-2001 00:00', endtime='29-nov-2001 00:00:00', samplingmode=interp, intervalmilliseconds=1h
SELECT timestamp, sim*.*, sim*.description, sim*.lastmodifieduser FROM ihtrend
WHERE sim*.description LIKE '*sim*'
AND sim*.description like '*first*'
AND *.datatype = singlefloat
ORDER BY simulation00001.value DESC, timestamp