Configures the metrics to be calculated and displayed.
name
, an optional description
, and a script
that calculates the metric. Optionally, you can set a hidden
property to true to hide the metric from the UI.
Inside one metric, you can use another metric through the available object Metric
like this: Metric["licenses_to_renew"]
.
The most important part of the metric definition is the Javascript code. This script can use ES2023 JS syntax and it must implement a function body that returns a number representing the computed metric value. Within a script, the following functions and objects are available:
ds
and dsAll
: Accessors to the dataset used as input. dsAll
refers to the entire dataset, while ds
is affected by the applied selection. If no selection is made, both accessors refer to the same dataset.count(ds)
: A function that returns the number of rows in the dataset.where("queryString", () => { /* 'ds' accessor is a subset filtered by the query and the global selection */ })
: A function that applies a filter to the ds
accessor. Note that dsAll
remains unaffected. Multiple where
calls can be nested. See Advanced query filters for more information on query strings.Metrics
: You can reference another metrics within a metrics script using the Metrics
object, e.g., Metrics["licenses_to_renew"]
..nullRows
: Returns the number of null rows in the column..validRows
: Returns the number of non-null rows in the column..count
: Returns the number of non-null values in the column. If the column is a List this will count each element..sum
: Calculates the sum of all values in the column..stddev
: Calculates the standard deviation of the values in the column..variance
: Calculates the variance of the values in the column..mean
: Calculates the average of all values in the column..min
: Returns the minimum value in the column..p25
: Calculates the 25th percentile of the values in the column..p50
: Calculates the 50th percentile (median) of the values in the column..median
: An alias for .p50
, calculates the median of the values in the column..p75
: Calculates the 75th percentile of the values in the column..max
: Returns the maximum value in the column..count
: Returns the number of non-null values in the column. If the column is a List this will count each element..uniqueValues
: Returns the number of unique values in the column..wordCount
: Calculates the total number of words across all non-null rows in the column.Examples
ds.first_name
), datasets (ds
or ds[["first_name", "last_name"]]
) or models (referenced
by name e.g. "churn-clf"
).
Inputs
Outputs
step(..., {"param": "value", ...}) -> (output)
.
Parameters
Array items
ABSOLUTE
RELATIVE
ABSOLUTE
RELATIVE