All Products
Search
Document Center

IoT Platform:Configure adjacent message calculation

Last Updated:Jun 20, 2026

The Adjacent Message Calculation node compares a numeric field (BIGINT or DOUBLE) between the current and previous messages, calculates a result using a defined expression, and writes it to a specified output field for further analysis.

Use cases

A smart meter reports its cumulative electricity usage every hour. To determine the incremental usage over the last hour (in kWh), you can use an Adjacent Message Calculation node to subtract the previous usage value from the current one.

Prerequisites

Ensure that data calculation expressions or data filtering filters are configured. For more information, see Configure data computing and data filtering.

Background information

Procedure

  1. Access the data parsing workbench.

  2. In the middle canvas, click the add image icon following the current node.

  3. In the node list that appears, click the Adjacent Message Calculation node.

  4. On the canvas, click the Adjacent Message Calculation node. In the configuration pane on the right, configure the node as described in the following table.

    Parameter

    Parameter

    Description

    Example

    basic settings

    previous variable field

    Select a numeric field from the previous message for the calculation.

    The ${pre_var} variable represents this field's value in the expression.

    Important

    This field supports only numeric fields (BIGINT or DOUBLE) from the output of the previous node.

    In the smart meter use case, select the electricity usage field, such as kWh.

    current variable field

    Select a numeric field from the current message for the calculation.

    The ${current_var} variable represents this field's value in the expression.

    Important

    This field supports only numeric fields (BIGINT or DOUBLE) from the output of the previous node.

    In the smart meter use case, select the electricity usage field, such as kWh.

    result field name

    Enter a name for the field that will store the calculation result.

    The name must be unique, up to 30 characters long, and contain only letters, digits, and underscores (_). It cannot start with a digit.

    For the smart meter use case, you can name the field kwh_diff to represent the incremental hourly electricity consumption.

    expression

    Define the expression to calculate the values from the previous variable field and current variable field.

    You must use ${current_var} to represent the value of the current variable field and ${pre_var} to represent the value of the previous variable field.

    You can use basic arithmetic operations and all functions that the expression node supports. For more information, see Configure expressions.

    For the smart meter use case, to calculate the incremental hourly electricity consumption, subtract the previous usage value from the current one.

    The expression is: ${current_var} - ${pre_var}.

    advanced settings

    message partition key

    Optional. The key used to partition messages within the same topic for adjacent calculations. Messages with the same partition key are processed sequentially.

    If you do not specify a key, IoT Platform uses the combination of ProductKey and DeviceName as the default message partition key.

    For the smart meter use case:

    To perform adjacent calculations on electricity consumption (kWh) messages from the same meter, the partition key should be the meter's ProductKey and DeviceName. In this case, you can leave this field empty to use the default.

    However, if multiple meters report data through a single gateway and a deviceId field in the message payload identifies each meter, you must set the message partition key to deviceId. This ensures that messages from the same physical meter are processed sequentially.

    message TTL

    Unit: seconds. Default: 86,400 (one day). Minimum: 1. Maximum: 2,592,000 (30 days).

    • If no new message is received within this duration, the previous variable's value is cleared. The node resets the message TTL each time it receives a new message.

    • If the message TTL expires and the previous variable's value is cleared, the system treats the next incoming message as the first in its sequence. The adjacent calculation does not run on this first message, and the result field is empty.

    For the smart meter use case, you can use the default value of 86400.

  5. Click Save in the upper-right corner of the Data Parsing console to save the node's configuration.

    Important

    The output of this node includes the specified result field and all output fields from the previous node.

Next steps

Continue building your data parsing pipeline by adding processing nodes or configuring a target node.