Create Formula

LLM-friendly URL
POST
https://api.luzmo.com/0.1.0/formula
API call form
Examples

Create a new formula.

After creating the formula, associate it to a specific dataset (Securable).

Note: during creation of formula, expressions will be validated. You can also validate the expression before creation using the validate action.

We support following functions in expression:

  • AVG({<dataset_ID>:<column_ID>})

  • COUNT({<dataset_ID>:<column_ID>})

  • COUNTD({<dataset_ID>:<column_ID>})

  • COUNTR()

  • MAX({<dataset_ID>:<column_ID>})

  • MIN({<dataset_ID>:<column_ID>})

  • SUM({<dataset_ID>:<column_ID>})

Derived column expressions can be combined with these aggregators. See this Academy article for the available operators.

Use GROUPFULL(aggregation) to ignore chart dimensions (filters still apply). Use GROUPINEX(aggregation, [columns to group by], [columns to exclude]) to include or exclude grouping columns. Nested aggregations wrap an inner grouped aggregation, for example AVG(GROUPINEX(SUM(...), [{<dataset_ID>:<column_ID>}], [])) . See Aggregation formulas .

Example:

"expression": "COUNTD({<orders_dataset_id>:<order_id_column_id>}) / COUNTD({<orders_dataset_id>:<store_id_column_id>})"

Filtering formula results: When querying data, use a having filter to keep groups whose calculated formula result meets a condition, such as a rate above a target or a score below a threshold. These filters apply after aggregation and grouping. See Having filters .

A formula created by an embed token of a tenant is assigned to that tenant automatically. This requires use on the dataset through the token's tenant_fields_rights (or rights , if tenant_fields_rights is not set). See Custom fields per tenant .

Request parametersResponse schema
id UUID

The unique identifier of the entity

name Multilingual string

Internationalized name of the formula.

description Multilingual string

Internationalized description of the formula.

ai_context STRING

Plain-text AI context for this formula. Luzmo IQ uses this field as additional business context when answering questions or generating charts. It enriches, but does not replace, the formula name, description, and expression. This field is shared across all languages and is not internationalized. Set it to null to clear previously stored AI context. The API stores and returns the full value; long values may be truncated only when rendered into AI prompts.

expression STRING
No description available
type STRING
No description available
subtype STRING
No description available
format STRING
No description available
informat STRING
No description available
lowestLevel NUMBER
No description available
currency_id STRING

Currency ID for this column. The currency_id is expected in the form of an ISO 4217 currency code , for example: EUR or USD .

custom_metadata OBJECT

Custom metadata attached to this formula. Must be a valid JSON object with a maximum size of 65536 bytes. Set to null to clear previously stored metadata.

created_at DATETIME

RFC 3339 date time string indicating when the resource was created

updated_at DATETIME

RFC 3339 date time string indicating when the resource was last updated

user_id STRING

ID of the user that owns this formula.

Can be executed by:
Logged-in User
Can be associated to:
Currency
Dataset
User
Tenants
Did this page help you?
Yes No
Language
Shell
Node
Java
.NET
Python
PHP
Install
npm install @luzmo/nodejs-sdk
Example Response
200
400
500
{
  "count": 1,
  "rows": [
    {
      "created_at": "2024-05-20T12:44:23.163Z",
      "currency_id": null,
      "description": {
        "en": "Unique orders divided by stores represented in the selected data"
      },
      "ai_context": null,
      "expression": "COUNTD({<orders_dataset_id>:<order_id_column_id>}) / COUNTD({<orders_dataset_id>:<store_id_column_id>})",
      "format": ",.2af",
      "id": "a1ad615a-5199-4e58-8e0e-73dceba18af0",
      "informat": "numeric",
      "lowestLevel": 0,
      "name": {
        "en": "Orders per active store"
      },
      "subtype": null,
      "type": "numeric",
      "updated_at": "2024-05-20T13:29:37.273Z",
      "custom_metadata": null,
      "user_id": "34b22f36-4904-497f-8acf-b0ba1d7e83cb"
    }
  ]
}