Skip to main content

Reading aggregated historical data

Learn how to retrieve aggregated (processed) historical data using server-side calculations.

What is Aggregated Data?​

Instead of reading every raw data point, aggregated data provides statistical summaries over time intervals (e.g., hourly averages, daily maximums).

Basic Configuration​

  1. OPC UA History Read node settings:
    • History Type: Processed Details
    • Aggregate Type: Average (or other function)
    • Processing Interval: Time interval for aggregation

Simple Hourly Averages​

[ Inject ] → [ Function ] → [ History Read ] → [ Chart ]

Function Node:

msg.nodeId = "ns=2;s=Temperature";
msg.startTime = "7 days ago";
msg.endTime = "now";
msg.processingInterval = "1 hour";
return msg;

History Read Node:

  • History Type: Processed Details
  • Aggregate Type: Average

Output:

msg.payload: [
{ value: 23.4, sourceTimestamp: "2024-11-20T00:00:00Z" },
{ value: 23.8, sourceTimestamp: "2024-11-20T01:00:00Z" },
{ value: 24.2, sourceTimestamp: "2024-11-20T02:00:00Z" }
// ... one value per hour
]

Common Aggregate Types​

Average - Mean Values​

// Daily average temperatures
msg.processingInterval = "1 day";
// Aggregate Type: Average

Maximum - Peak Values​

// Find hourly peak pressure
msg.processingInterval = "1 hour";
// Aggregate Type: Maximum

Minimum - Low Points​

// Find daily minimum levels
msg.processingInterval = "1 day";
// Aggregate Type: Minimum

Count - Data Point Count​

// Count data points per 5 minutes
msg.processingInterval = "5 minutes";
// Aggregate Type: Count

Total - Sum of Values​

// Sum energy consumption per hour
msg.processingInterval = "1 hour";
// Aggregate Type: Total

Practical Examples​

Daily Production Summary​

msg.nodeId = "ns=2;s=ProductionCount";
msg.startTime = "30 days ago";
msg.endTime = "now";
msg.processingInterval = "1 day";
// Aggregate Type: Total
return msg;

Quality Monitoring​

msg.nodeId = "ns=2;s=QualityMetric";
msg.startTime = "1 week ago";
msg.endTime = "now";
msg.processingInterval = "1 hour";
// Aggregate Type: PercentGood
return msg;

5-Minute Trend Data​

msg.nodeId = "ns=2;s=ProcessVariable";
msg.startTime = "2 hours ago";
msg.endTime = "now";
msg.processingInterval = "5 minutes";
// Aggregate Type: Average
return msg;

Processing Intervals​

Common interval formats:

  • "30 seconds"
  • "5 minutes"
  • "1 hour"
  • "1 day"
  • "1 week"

Tips​

  • Use aggregation to reduce data volume for charts
  • Choose intervals based on your analysis needs
  • Aggregation is done server-side (fast and efficient)
  • Different aggregates answer different questions:
    • Average: Typical behavior
    • Max/Min: Extremes and ranges
    • Total: Cumulative values
    • Count: Data availability