---
title: Using Calculated Event Properties
slug: how-tos/JiU1-using
docTags: MOqdYKMyvxcUdfxom4ZwP,HM2rWeeWAO1-Dgm69CZmi,-lEpQUJUrHKsDoceamiiX,eoKZTKp5MQ-prmF2dyzcR
createdAt: 2025-08-21T18:37:37.974Z
---

## Introduction

With Factry Historian v8.0, we're bringing calculation scripts to [event](docId:0Ith2zLcAIs5YYwhSdTjE) properties. This feature allows you to develop more complex use cases in Factry Historian.

Calculated Event Properties work similarly to [Calculations](docId\:OpIoDkGNNgYjeDX6zkg_D) (which apply to time-series data), because they rely on one or more inputs, a Tengo script, and they return an output.

This makes it a great feature for use cases such as:

- Calculating KPIs
- Calculating yields for material and energy
- Calculating quality characteristics based on test results
- Product traceability

## Example case

In this example case, we're exploring a typical use case in yeast production to calculate the efficiency and yield of the fermentation process. Fermentation is a batch process, which makes it an ideal use case for the Events processing functionality in Factry Historian.

To verify the performance of the production batch once fermentation is done, we want to calculate the following properties:

1. Yeast output in fermenter \[kg] (dry weight of produced yeast biomass; based on final spin test result & final volume in fermenter)
2. Yield in fermenter \[%] (yeast output in fermenter \[kg] / fed molasses \[kg])

### Yeast output (kg)

Yeast output will be calculated by taking a sample of the fermentation broth when the fermentation has ended, and determining the (dry) yeast content per volume of the broth. This then needs to be multiplied with the final volume of broth in the fermenter when the fermentation ended, to obtain the total amount of yeast.

```tex
m_{\text{yeast}} \;=\; 
\left( \frac{m_{\text{sample,dry}}}{V_{\text{sample}}} \right) \cdot V_{\text{final}}
```

### Yield in fermenter (%)

The fermenter yield is a measure of how efficiently the carbon source (molasses, typically) has been "converted" to yeast biomass. This will be calculated by dividing the yeast output by the fed molasses, on dry weight basis.

```tex
Y_{\text{fermenter}} \;=\; 
\frac{m_{\text{yeast}}}{m_{\text{molasses}}}
```

## Let's get to work

### Available data

In the example case for our fermenter, we have the following measurements coming into Factry Historian from the SCADA system controlling the fermentation:

- F1\_BatchID - The Batch ID
- F1\_ProgramStep - The PLC program step
- F1\_Volume - Volume of material in the fermenter \[L]
- F1\_MolasseTotal - Molasse feed totalizer \[kg]

And our operators take a sample of the fermentation broth at the end of fermentation and determine the volume of it in the lab, as well as the dry matter content.

### Asset Property configuration

We configure our fermenter asset in the Asset tree, together with its [Asset Properties](docId\:Cr6HbrDSl8FsuVlVm20IF).

**Fermenter 1:**

- BatchID -> linked to F1\_BatchID measurement
- Status -> linked to F1\_ProgramStep measurement
- Volume -> Linked to F1\_Volume measurement
- Molasse feed totalizer -> Linked to F1\_MolasseTotal measurement

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/ueB0KcoD4-HwL7N4IbMwq-20251205-135525.png)

### Event configuration

We configure a **Fermentation Batch** Event type and configure the following properties:

- BatchID
- FinalFermenterVolume \[L]
- MolasseTotal \[kg]
- FinalSampleDryMatter \[kg]
- FinalSampleVolume \[L]
- YeastOutput \[kg]
- FermenterYield \[%]

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/fafbpy0ij-hTBD70sVpIg-20251205-135910.png)

Then we attach the **Fermentation** **Batch** event type to Fermenter 1 in our asset tree, and configure "historian" as the detection mode to trigger the start and stop times of the Fermentation Batch event, based on the **Status** asset property of the **Fermenter 1** asset.

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/MXk3Fsx808bBQ7uPDWoTb-20251205-140117.png)

Once attached, we configure the event properties as such, with priority 0:

- BatchID -> BatchID asset property, with 'first' as aggregation
- FinalFermenterVolume -> Volume, last
- MolasseTotal -> Molasse feed totalizer, last
- FinalSampleDryMatter -> Manual
- FinalSampleVolume -> Manual

The first 3 event properties are known in Historian, because they are collected from the SCADA system. We set these to detection mode **historian**.

Because the last 2 are test results from the lab, we configure these with detectio mode **manual**.

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/FkyBoJSicrNbtEGLe77oN-20251205-140315.png)

### Manual Entry Form configuration

To obtain the final sample dry matter and volume, we set up a [Manual Entry Form](docId\:E6ZVm8L_ZLpfpCHDTQU0H) to enable the operator to enter those 2 values on the Batch event manually.

Once configured, the (lab) operator is presented with the interface as seen below, and enters the values for Final Sample Dry Matter and Final Sample Volume.

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/8ep2rGReZwY9cmfrOEDIx-20251205-140556.png)

### Calculated Event Properties configuration

Now we should have all data available to perform our calculations: 3 values coming from SCADA, 2 values from manual entry.

We can now configure the final 2 event properties as **Calculated Event Properties** on the Fermentation Batch event type:

### YeastOutput

We define YeastOutput with **detection mode** calculation, taking **FinalSampleDryMatter**, **FinalSampleVolume** and **FinalFermenterVolume** as inputs.

We give this calculation priority 1, as it is dependent on FinalFermenterVolume (coming from Historian) and FinalSampleDryMatter & FinalSampleVolume, coming from the Manual Entry Form we configured before.

Once configured, YeastOutput will be calculated automatically in Factry Historian once all 3 input event properties are known.

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/rkWaXvCm6DappSbxLEG1C-20251205-140811.png)

### FermenterYield

We define FermenterYield with **detection mode** calculation, taking YeastOutput and MolasseTotal as inputs. MolasseTotal comes from Historian, and YeastOutput is itself a calculation. We give this event property the priority 2.

Once both event properties are known, FermenterYield is calculated automatically by Factry Historian.

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/Ub0PsZnj-HN-hLXterSSu-20251205-141115.png)

### Outcome

Using the setup above, Factry Historian's event processor will constantly process data in the background and calculate the YeastOutput and FermenterYield event properties.

In Grafana, we can now easily display these batches using the [Factry Historian Datasource plugin](https://grafana.com/grafana/plugins/factry-historian-datasource/) by selecting the Events tab, browsing the Asset structure to select Fermenter 1, and selecing the **Fermentation Batch** event.

![](https://api.archbee.com/api/optimize/SMPo4IS9FkillUAMsur2c/tlb-3as0eOiOGCqIYXDBV-20251205-144111.png)

You can see the example dashboard here: [https://demo.factry.io/d/df66nb5ez36rka/fermentation-dashboard](https://demo.factry.io/d/df66nb5ez36rka/fermentation-dashboard)

## Conclusion

We believe this feature will unlock a lot of value for our users, who can now calculate KPIs automatically using data coming from their control systems, and optionally from manual entry.

We can't wait to see what our users build with this functionality.
