# Column Calculation

## **Specs**

| Label                     | Value                         |
| ------------------------- | ----------------------------- |
| **Version**               | 0.1.0 (updated on 2025-08-07) |
| **Developer**             | Labii Inc.                    |
| **Type**                  | Column                        |
| **Support Configuration** | Yes                           |
| **Support Readonly view** | Yes                           |
| **Support Edit view**     | No                            |
| **Support Form view**     | No                            |
| **Support Default value** | No                            |
| **Support Import**        | No                            |
| **Allow multiple**        | Yes                           |

## Overview

The Labii **Column Calculation** widget enables powerful real-time data aggregation by allowing users to perform statistical operations—such as sum, average, maximum, minimum, median, standard deviation, and standard error—on values from an origin column across records that reference the current record. This widget is especially useful for automating complex calculations like material consumption, total check-in/check-out counts, yield analysis, and other cumulative metrics. By eliminating the need for manual computation and ensuring up-to-date values, the **Column Calculation** widget streamlines data tracking and enhances analytical precision across workflows.

The **Column Calculation** widget eliminates the hassle of manually converting values between different units. By configuring the conversion factor within the widget's settings, it can seamlessly perform automatic unit conversions.

<figure><img src="https://3607108856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHVg57XIRcjV-Vbubtn%2Fuploads%2Fgit-blob-11b30b27a31481e0f12dcaf73f638a4ba5980084%2Fwidget-column-column-calculation-design.webp?alt=media" alt=""><figcaption></figcaption></figure>

## Use case

* Use this widget to calculate the total checkin volume.
* Use this widget to calculate the total invoice amount.
* Use this widget to calculate the yield.

## Configuration

To configure the widget, specify the data to be calculated and the desired calculation method.

* **Columns of current table**
  * **Column (Unit)** - Choose the column for unit. If this column is left blank, no unit conversion will be performed.
* **Origin table settings**
  * **Table (Origin)** - Select a table that stores the original data.
  * **Column (Source) of the Origin table** - Select the column in the origin table that is associated with the current record.
  * **Column (Value) of the Origin table** - Select the column in the origin table that is associated with the current record.
  * **Column (Unit) of the Origin table** - Choose the column in the origin table that records the unit of the value. If this column is left blank, no unit conversion will be performed.
  * **Query** - Further refine the displayed records by adding supplementary query criteria.
* **Calculation settings**
  * **Data aggregation** - Select how to aggregate the data for the value. Options include sum, average, max, median, min, standard deviation, and standard error.
  * **Conversions** - Specify the conversion factors for every unit utilized, ensuring inclusion of all units within the quantity unit. If a unit is not provided, a factor of 1 will be utilized.
  * **Stop condition** - The formula will stop calculation when the condition is met. It must return a `true` or `false` value. This field does not support other column data, you can only use the variable `data` to reference the current record data.
  * **Should auto update when readonly** - If checked, this widget will perform a live calculation when readonly.

### Example

Below is the widget configuration for performing calculations using data from the consumption table.

```json
{
    "current_unit": {
        "sid": "xxx",
        "name": "unit"
    },
    "origin_table": {
        "sid": "xxx",
        "name": "checkin"
    },
    "stop_condition": "data !== \"\"",
    "data_aggregation": "se",
    "origin_column_unit": {
        "sid": "xxx",
        "name": "unit"
    },
    "origin_column_value": {
        "sid": "xxx",
        "name": "quantity"
    },
    "origin_column_source": {
        "sid": "xxx",
        "name": "stock"
    },
    "should_auto_update_when_readonly": false
    "conversions": [
        {
            "unit": "µL",
            "factor": 1
        },
        {
            "unit": "mL",
            "factor": 1000
        },
        {
            "unit": "L",
            "factor": 1000000
        },
        {
            "unit": "µg",
            "factor": 1
        },
        {
            "unit": "mg",
            "factor": 1000
        },
        {
            "unit": "g",
            "factor": 1000000
        },
        {
            "unit": "kg",
            "factor": 1000000000
        },
        {
            "unit": "Each (EA)",
            "factor": 1
        },
        {
            "unit": "Dozen (DZ)",
            "factor": 1
        },
        {
            "unit": "Gross (GR or GRO)",
            "factor": 1
        },
        {
            "unit": "Pair (PR)",
            "factor": 1
        },
        {
            "unit": "Case (CS or CA)",
            "factor": 1
        },
        {
            "unit": "Pack (PK)",
            "factor": 1
        },
        {
            "unit": "Bundle (BDL)",
            "factor": 1
        },
        {
            "unit": "Carton (CTN)",
            "factor": 1
        },
        {
            "unit": "Set (SET)",
            "factor": 1
        },
        {
            "unit": "Roll (RL)",
            "factor": 1
        }
    ]
}
```

## Views

See the interface of the widget in the following views.

### **Readonly view**

Readonly view display the values of the column.

<figure><img src="https://3607108856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHVg57XIRcjV-Vbubtn%2Fuploads%2Fgit-blob-c6826a78904eaf8f564e989092b55949a3528365%2Fwidget-column-column-calculation.webp?alt=media" alt=""><figcaption></figcaption></figure>

In the readonly view, a warning message will be shown when the remaining volume is equal to or less than the specified threshold.

### **Edit view**

The Edit view is the interface that allows you to modify the value.

Edit view is not supported for this widget.

### **Form view**

The Form view is the field integrated into the add form for collecting values when creating a new record.

Form view is not supported for this widget.

## Data

Each widget in Labii stores data in a unique manner; refer below to understand how data from this widget is stored.

### Data format

Numeric values.

### **Default value**

The Default Value field within the column allows you to specify the default value when a record is created.

Default value is not supported for this widget.

### **Import value**

The Import Value is the value you need to include in your Excel table for it to be imported into Labii.

Import value is not supported for this widget.
