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
Expand all Reset
properties *OBJECTrequired
id UUID
name Multilingual string
description Multilingual string
ai_context STRING
expression STRING
type STRING
subtype STRING
format STRING
informat STRING
lowestLevel NUMBER
currency_id STRING
custom_metadata OBJECT
created_at DATETIME
updated_at DATETIME
user_id STRING
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"
    }
  ]
}