Add Values From Two Fields

Calculate the sum of values from two fields using the addition operator (+)

Query

flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[[Expression]] result{{Result Set}} repo --> 1 1 --> result
logscale
result:=a+b

Introduction

Mathematical operations can be performed on field values to calculate new results. Multiplication, addition, subtraction and division do not require usage of a function.

In this example, addition is used to calculate the sum of values from fields a and b, storing the result in a new field.

Example incoming data might look like this:

@timestampab
2025-09-15T10:00:00Z24
2025-09-15T10:00:01Z53
2025-09-15T10:00:02Z102
2025-09-15T10:00:03Z36
2025-09-15T10:00:04Z85

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[[Expression]] result{{Result Set}} repo --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    result:=a+b

    Adds the values in fields a and b and assigns the result to a new field named result. The addition operator (+) performs the calculation on the numerical values from both fields.

  3. Event Result set.

Summary and Results

The query is used to add values from two different fields and store the result in a new field.

This query is useful, for example, to calculate total scores (score1 + score2), combined quantities (inventory + new_stock), or any other addition-based calculations from field values.

Sample output from the incoming example data:

abresult
246
538
10212
369
8513

The results of this addition query can be effectively visualized using various widgets. A Time Chart widget could show how the sum values change over time. For comparing the original values with their sums, a Table widget would be most appropriate, allowing side-by-side comparison of the input fields and their calculated results.