Get historical data items by timespan (GetData)

The GetData() function retrieves all data items posted to the Platform by a specified data item during a defined time period. This function cannot return more than 100 values. Since it returns an array of values, this function MUST be used within a statistical function - either min(), max(), or avg().

Important! This function is available only if the Platform is configured to enable historical functions.

In general, the historical data functions retrieve data from the Platform, which can slow response time for rules processing.
To ensure optimal response time, Axeda strongly recommends that you limit the amount of data these functions retrieve, the frequency that the expression rules that use them run, and the number of assets associated with expression rules that use them. For example, do not request historical data more than once per second.  

If no data exists for a specified data item or time frame, then the function returns an empty array.

Format:

Array GetData (String dataitemname, int timespan, int max)


Where:

dataitemname - The name of data item

timespan - The number of minutes, hours, days, weeks, or months; see how to define timespan values; unless defined otherwise, uses minutes as value, by default.

max - Optional; the maximum number of data item values to be returned. The function does not return more than 100 data items.

Use the following format when nesting this function in a statistical function:

min(GetData(String dataitemname, int timespan, int max))

The min function would return the smallest data item posted during the timespan. The max function returns the largest data item posted during the timespan.

 

Examples:

The following expression retrieves up to 20 values for temperature that were logged within the last 10 minutes and determines if the highest temperature is over 100.

If max(GetData("temperature", 10, 20)) > 100

The following expression retrieves up to five values for temperature that were logged within the last 3 days and determines if the lowest temperature is below 0.

If min(GetData("temperature", 3d, 5)) < 0 Then do something

The following expression retrieves all values for temperature that were logged for the past week, and determines if the average temperature is below 0:

If avg(GetData("temperature", 1w))< 0 Then do something, for a week

 

See Also