Minimum/Maximum and MinimumTime/MaximumTime Modes

The minimum (or maximum) value in the interval and the time stamp of that value.

Value

Maximum returns the raw or interpolated value with the greatest value and good data quality in the interval. Minimum returns the raw or interpolated value with the lowest value and good data quality in the interval

MaximumTime returns the time stamp of the Maximum value. MinimumTime returns the time stamp of the Minimum value.

In all cases, all raw samples of bad quality is ignored, both during interpolation and when calculating the maximum.

Quality

If the raw samples in the interval all have bad quality, or if the sample before the interval has bad quality, then percent good is 0. Otherwise, percent good is always 100, even if the interval does not contain any raw samples or contains both good and bad quality samples.

Example: Finding minimum and maximum of Downward Sloping Data

The following example demonstrates how a raw sample is interpolated at the interval's start and end time and how this interpolation is used with raw samples when calculating minimum and maximum values.

Import the following data:

[Tags]
Tagname,DataType,HiEngineeringUnits,LoEngineeringUnits
DOWNSLOPE,SingleFloat,100,0
[Data]
Tagname,TimeStamp,Value,DataQuality
DOWNSLOPE,29-Mar-2002 13:59:00.000,22,Good
DOWNSLOPE,29-Mar-2002 14:08:00.000,12,Good
DOWNSLOPE,29-Mar-2002 14:22:00.000,4,Good

The following query retrieves the Maximum value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=Maximum and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = DOWNSLOPE and numberofsamples = 8
The following query retrieves the MaximumTime:
select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=MaximumTime and timestamp 
>= '29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = DOWNSLOPE and numberofsamples = 8
The following query retrieves the Minimum:
select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=Minimum and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = DOWNSLOPE and numberofsamples = 8

The following query retrieves the MaximumTime value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=MinimumTime and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = DOWNSLOPE and numberofsamples = 8

The following query retrieves the Minimum value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=Min

The following query retrieves the MinimumTime value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=MinimumTime and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = DOWNSLOPE and numberofsamples = 8
Interval Time StampMaximumMaximum TimeMinimumMinimum TimeQuality
13:55:00.0000.0031-Dec-1969 19:00:00.0000.0031-Dec-1969 19:00:00.0000.00
14:00:00.00022.0013:59:00.00020.8914:00:00.000100.00
14:05:00.00020.8914:00:00.00015.3314:05:00.000100.00
14:10:00.00015.3314:05:00.00010.8614:10:00.000100.00
14:15:00.00010.8614:10:00.0008.0014:15:00.000100.00
14:20:00.0008.0014:15:00.0005.1414:20:00.000100.00
14:25:00.0005.1414:20:00.0004.0014:25:00.000100.00
14:30:00.0004.0014:30:00.0004.0014:30:00.000100.00

The value is 4 for the entire interval of 14:26:00 to 14:30:00. However, the newest value is always returned for MinimumTime and MaximumTime for an interval, so the values instead are calculated as 14:30.

All modes have the same quality. A MaximumTime or MinimumTime of 1969 means there is no value in that interval.

Maximum always begins at the start of the interval because the data forms this is a downwards-sloping line. The Maximum takes the sample interpolated at the interval start time. The timestamp is still the interval end time.

When an interval has no raw samples, such as in the 14:05 interval, samples are interpolated at the beginning and the end of the interval. This means that the 14:05 interval has 2 samples to example at when calculating the Minimum or Maximum.

Example: Finding Minimum and Maximum of Changing Data

The following example uses a value that continually changes, rather than one that simply slopes upwards or downwards. Any Minimum or Maximum within an interval is necessarily a raw sample. If the minimum or maximum occurred as raw samples in the middle of the interval, these are also detected.

Import the following data:

[Tags]
Tagname,DataType,HiEngineeringUnits,LoEngineeringUnits
SAWTOOTH,SingleFloat,60,0

[Data]
Tagname,TimeStamp,Value,DataQuality
SAWTOOTH,29-Mar-2002 13:59:00.000,22.7,Good
SAWTOOTH,29-Mar-2002 14:01:00.000,12.5,Good
SAWTOOTH,29-Mar-2002 14:02:00.000,47.0,Good
SAWTOOTH,29-Mar-2002 14:03:00.000,2.4,Good
SAWTOOTH,29-Mar-2002 14:04:00.000,9.5,Good
SAWTOOTH,29-Mar-2002 14:08:00.000,12.5,Good
SAWTOOTH,29-Mar-2002 14:14:00.000,7.0,Good
SAWTOOTH,29-Mar-2002 14:22:00.000,4.8,Good

The following query retrieves the Maximum value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=Maximum and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = SAWTOOTH and numberofsamples = 8

The following query retrieves the MaximumTime value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=MaximumTime and timestamp 
>= '29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = SAWTOOTH and numberofsamples = 8

The following query retrieves the Minimum value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=Minimum and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = SAWTOOTH and numberofsamples = 8

The following query retrieves the MinimumTime value:

select timestamp, value, quality from ihrawdata where samplingmode=calculated and calculationmode=MinimumTime and timestamp >= 
'29-Mar-2002 13:50' and timestamp <= '29-Mar-2002 14:30' and tagname = SAWTOOTH and numberofsamples = 8
Interval Time StampMaximumMaximum TimeMinimumMinimum TimeQuality
13:55:00.0000.0031-Dec-1969 19:00:00.0000.0031-Dec-1969 19:00:00.0000.00
14:00:00.00022.7013:59:00.00017.6014:00:00.000100.00
14:05:00.00047.0014:02:00.0002.4014:03:00.000100.00
14:10:00.00012.5014:08:00.00010.2514:03:00.000100.00
14:15:00.00010.6714:10:00.0006.7314:15:00.000100.00
14:20:00.0006.7314:15:00.0005.3514:20:00.000100.00
14:25:00.0004.8014:20:00.0004.8014:25:00.000100.00
14:30:00.0004.8014:30:00.0004.8014:30:00.000100.00

Querying with a single interval so that all samples are included results in the following:

Interval Time StampMaximumMaximum TimeMinimumMinimum TimeQuality
14:30:00.00047.0014:02:00.0002.4014:03:00.000100.00
Example: Finding the Minimum and Maximum with Bad Quality Data and Repeated Values

Import the following data:

[Tags]
Tagname,DataType,HiEngineeringUnits,LoEngineeringUnits
MINMAXBAD,SingleFloat,60,0

[Data]
Tagname,TimeStamp,Value,DataQuality
MINMAXBAD,29-Mar-2002 13:59:00.000,22.7,Good
MINMAXBAD,29-Mar-2002 14:01:00.000,12.5,Good
MINMAXBAD,29-Mar-2002 14:02:00.000,47.0,Bad
MINMAXBAD,29-Mar-2002 14:03:00.000,2.4,Bad
MINMAXBAD,29-Mar-2002 14:04:00.000,9.5,Good
MINMAXBAD,29-Mar-2002 14:08:00.000,12.5,Good
MINMAXBAD,29-Mar-2002 14:14:00.000,7.0,Good
MINMAXBAD,29-Mar-2002 14:22:00.000,4.8,Good

Querying with a single interval so that all samples are included results in the following:

Interval Time StampMaximumMaximum TimeMinimumMinimum TimeQuality
14:30:00.00022.7013:59:00.004.8014:30:00.000100.00
Note: MinimumTime is not 14:22 but 14:30. When multiple values within an interval have the same Minimum or Maximum value, (such as here, where two samples have a minimum of 4.8), the newest time stamp is always taken.