Query Modifiers

Query modifiers are used to retrieve data that has been stored in the archive. They are used along with sampling and calculation modes to get a specific set of data.

If you want to use a query modifier, when you create or modify a query, in the Query Criteria String field, enter #, and then enter the query modifier. For example, if you want to retrieve only good data quality values, enter #ONLYGOOD.

Query Modifier Results
ONLYGOOD Excludes bad and uncertain data quality values from retrieval and calculations.

Although you can use this modifier with any sampling or calculation mode, it is most useful with raw and current value queries. All the calculation modes such as minimum or average exclude bad values by default, so this modifier is not required in those cases.

INCLUDEREPLACED Normally, when you query raw data, any values that have been replaced with a different value for the same timestamp are not returned.

The INCLUDEREPLACED modifier is used to specify that you want replaced values to be returned, in addition to the updated values. However, you cannot query only the replaced data and the retrievable values that have replaced the other values. You can query all currently visible data and get the data that has been replaced.

This modifier is only useful with the rawbytime or rawbynumber retrieval. Do not use it with any other sampling or calculation mode.

INCLUDEDELETED Retrieves the value that was previously deleted. Data that has been deleted from the archiver is never actually removed but is marked as hidden. Use the INCLUDEDELETED modifier to retrieve the values that were deleted, in addition to the current values.

This modifier is only useful with the rawbytime or rawbynumber retrieval. Do not use it with any other sampling or calculation mode.

ONLYIFCONNECTED and ONLYIFUPTODATE

Retrieve bad data if the collector is not currently connected and sending data to the archiver. You can use these modifiers with any sampling or calculation mode.

The bad data is not stored in the IHA file but is only returned in the query. If the collector reconnects and flushes data and you run the query again, the actual stored data is returned in the following situations:
  • Collector loses connection to the archiver
  • Collector crashes
  • Collector compression is used and no value exceeds the deadband
ONLYRAWRetrieves only the raw samples. It does not add interpolated or lab sampled values at the beginning of each interval during calculated retrieval such as average, minimum, or maximum.

Normally, a data query for minimum value will interpolate a value at the start of each interval and use that together with any raw samples to determine the minimum value in the interval. Interpolation is necessary because some intervals may not have any raw samples stored.

Use this query modifier with calculation modes only, not with raw or sampled retrieval like interpolated modes.

LABSAMPLINGAffects the calculation modes that interpolate a value at the start of each interval. Instead of using interpolation, lab sampling is used. When querying highly compressed data, you may have intervals with no raw samples stored.

For example, an average from 2 pm to 6 pm on a one-hour interval will interpolate a value at 2 pm, 3 pm, 4 pm, and 5 pm, and uses those in addition to any stored samples to compute averages. When you specify LABSAMPLING, the lab sampling mode is used instead of the interpolated sampling mode to determine these hourly values. A lab sampled average is used when querying a tag that never ramps up but changes in a step pattern such as a state value or a set point. Use this query modifier with calculation modes only, not raw or sampled retrieval like interpolated modes.

ENUMNATIVEVALUE Retrieves the native, numeric values such as 1 or 2 instead of string values such as on/off for the data that has enumerated states associated with it.

You can use this modifier with any sampling or calculation mode.

INCLUDEBADNormally, when you query calculated data from Historian, only good data quality raw samples are considered. INCLUDEBAD modifier includes bad data quality values in calculations.

You can use this modifier with any sampling or calculation mode.

FILTERINCLUDEBADNormally, while filtering, we use only good data quality values. When we use FILTERINCLUDEBAD, the bad data quality values are considered when filtering to determine time ranges. This modifier is not always recommended.
USEMASTERFIELDTIMEReturns the value of all the fields at the same timestamp of the master field time, in each interval returned. It is used only for the multi-field tags.
HONORENDTIMENormally, a query keeps searching through archives until the required number of samples has been located, or until it gets to the first or last archive. However, there are cases where you would want to specify a time limit as well. For example, you may want to output the returned data for a RawByNumber query in a trend page, in which case there is no need to return data that would be off page.

If you want to specify a time limit, provide an end time in your RawByNumber query and include the HONORENDTIME query modifier. Since RawByNumber has direction (backward or forward), the end time must be older than the start time for a backward direction or later than the start time for a forward direction. Use this query modifier only with the RawByNumber sampling mode.

EXAMINEFEWQueries using calculation modes normally loop through every raw sample, between the given start time and end time, to compute the calculated values.

When using FirstRawValue, FirstRawTime, LastRawValue, and LastRawTime calculation modes, we can use only the raw sample near each interval boundary and achieve the same result. The EXAMINEFEW query modifier enables this. If you are using one of these calculation modes, you may experience better read performance using the EXAMINEFEW query modifier.

Using this query modifier is recommended when:
  • The time interval is great than 1 minute.
  • The collection interval is greater than 1 second.
  • The data node size is greater than the default 1400 bytes.
  • The data type of the tags is String or Blob. Query performance varies depending on all of the above factors.

Use this query modifier only with FirstRawValue, FirstRawTime, LastRawValue, and LastRawTime calculation modes.