> For the complete documentation index, see [llms.txt](https://easyedge.gitbook.io/easyedge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easyedge.gitbook.io/easyedge/how-to/edge-data-processing/use-expressions-to-calculate-data-at-the-edge.md).

# Use Expressions to Calculate Data at the Edge

In EasyEdge, Expressions can be used to calculate **new values** from existing data. This allows you to derive additional insights directly at the edge, ensuring applications receive meaningful data without requiring external processing.

Just like transformations, calculations can be applied at the **Tag level** or at the **Data Stream level**, depending on your project’s needs.

***

## EasyEdge Expression Assistant

When creating calculations, EasyEdge provides an **Expression Assistant** that works on both **Tags** and **Data Streams**.

* The assistant suggests available **functions** (such as `abs`, `avg`, `cos`, `sin`, etc.) as you type, helping you quickly build the calculation.
* Each input variable (`a`, `b`, `c`, …) is automatically linked to its corresponding **Tag or Data Field**, so you always know which value is being used in the expression.
* The syntax is validated in real time, and a confirmation bar shows when the expression is valid before you save it.

<figure><img src="/files/vFLSONoZwhYnf5J7KOSz" alt=""><figcaption></figcaption></figure>

This is especially useful for calculations that involve **multiple inputs** (e.g., Active Power and Apparent Power for Power Factor). It ensures your expression is clear, valid, and ready to be applied.

{% hint style="info" %}
💡 **Tip:** A full list of functions (including arithmetic, trigonometric, and logical operators) is available in the [Expressions - Operations Engine](/easyedge/reference/expressions-operations-engine.md) page.
{% endhint %}

***

## Example: Calculating Power Factor

A common example is calculating the **Power Factor (PF)**, which measures how efficiently electrical power is being used.

Power Factor can be calculated in different ways, depending on the inputs available. For this guide, we’ll use the simpler and more common formula:

```
PowerFactor = ActivePower / ApparentPower
```

### Tag Calculation

Tag-level calculations create **new Tags** from Expressions. Depending on where the input values come from, you can use:

#### Asset Tags

* Best when **all inputs come from the same Asset**.
* Example: If an Asset provides both **Active Power (kW)** and **Apparent Power (kVA)**, you can create an Asset Tag:

<figure><img src="/files/i5YBwwwwsIb68rcWkYb2" alt=""><figcaption></figcaption></figure>

* With the Expression:

<figure><img src="/files/z7XUgXjAUqWXvLU7Psfp" alt=""><figcaption></figcaption></figure>

* The Asset Tag will always return the calculated Power Factor.

#### Core Tags

* Best when **inputs come from different Assets**.
* Example: One Asset provides **Active Power (kW)** while another provides **Apparent Power (kVA)**.
* In Tag Central, create a Core Tag:

<figure><img src="/files/Ny2eLbjZlRFaCaDe2Vam" alt=""><figcaption></figcaption></figure>

* &#x20;With the Expression:

<figure><img src="/files/5oMArFfnP16zbArYptAb" alt=""><figcaption></figcaption></figure>

* The Core Tag will calculate Power Factor by combining values from both Assets.

### Data Stream Calculations

When using Data Streams, you can calculate new values **before delivering them to applications**.

* Example using **Active Power (kW)** and **Apparent Power (kVA).**
* Create the Data Stream for **Power Factor (PF):**

<figure><img src="/files/3gf192XK6JuD2IWCUsHN" alt=""><figcaption></figcaption></figure>

* With the Expression:

<figure><img src="/files/tamp9w84MJW6HxcFyBiB" alt=""><figcaption></figcaption></figure>

* This keeps the raw values available at the edge while delivering only the Power Factor to the target application.
* **Inputs can come from single or multiple Assets**.

***

## Key Considerations

* **Asset Tags** → Use when all inputs belong to a single Asset.
* **Core Tags** → Use when inputs need to be combined from different Assets.
* **Data Streams** → Use when calculations are application-specific, while keeping raw data intact at the edge.

***

{% hint style="info" %}
👉 Advanced note: The same principles can be applied to more complex calculations, such as **Reactive Energy (kVArh)**, which requires time-based integration of Reactive Power.
{% endhint %}
