LastRawValue/LastRawTime Modes

Retrieves the last good raw sample value or timestamp for a given time interval.

Value

The value of the raw sample or zero if there are no good raw samples in the interval. The timestamp of the sample or the year 1969 if there are no good raw samples in the interval.

Quality

The quality is the same for LastRawValue and LastRawTime. If there are no good raw samples in the interval, then the percent good is 0. Otherwise, percent good is always 100, even if the interval contains bad quality samples.

The Raw sample has a quality of Good, Bad or Uncertain, and that is converted to a 0 or 100 percent.

Example: Retrieving the LastRawValue/LastRawTime Values

Import this data into Historian

[Tags]Tagname,DataType
DecimatedOneHour,DoubleInteger
[Data]
Tagname,Timestamp,Value,DataQuality
Tag1,07-05-2011 17:29:00,29,Good
Tag1,07-05-2011 20:00:00,0,Good
Tag1,07-05-2011 20:12:00,12,Good
Tag1,07-05-2011 20:15:00,0,Bad
Using LastRawValue Calculation Mode
set starttime='07-05-2011 17:00:00',endtime=' 07-05-2011 21:00:00'
select timestamp,value,quality from ihrawdata where tagname like Tag1 and samplingmode=Calculated and 
CalculationMode=LastRawValue and Intervalmilliseconds=1h

The output is as follows:

Time StampValueQuality
07-05-201118:00:0029100.0000000
07-05-201119:00:0000.0000000
07-05-201120:00:000100.0000000
07-05-201121:00:0012100.0000000

In the interval from 17:00 to 18:00 the last good value is 29. The 18:00 to 19:00 has no raw samples so the quality is bad. The 20:00 sample is returned as the last good value in the 19:00 to 20:00. In the final interval, the last raw sample is bad quality so it is ignored and the previous sample is returned.

Using LastRawTime Calculation Mode
set starttime='07-05-2011 17:00:00',endtime=' 07-05-2011 21:00:00'
select timestamp,value,quality from ihrawdata where tagname like Tag1 and samplingmode=Calculated and CalculationMode=
LastRawTime and Intervalmilliseconds=1h

The output is as follows:

Time StampValueQuality
07-05-201117:00:0007-05-201117:29:00100.0000000
07-05-201118:00:0001-01-197005:30:000.0000000
07-05-201119:00:0007-05-201120:00:00100.0000000
07-05-201120:00:0007-05-201120:12:00100.0000000
Note: You can also use the INCLUDEBAD query modifier to include bad quality data.