Function reference

Every function the expression language understands — what it takes, what it gives back, whether it works on one entry or a whole column, and a copy-pasteable example.


This page is generated from the engine itself, so it can't drift: if a function is listed here it exists, and its example is one Kaizendex actually runs. For what expressions are and how to think about them, read The expression language first.

How to read the table

  • Function — the name and its arguments, in order. An argument ending in ? is optional; means you can keep adding more.
  • Gives back — the kind of value you get. series means a whole column comes back out, ready to feed into the next function.
  • ScopeRow works on a single entry (a Formula field), Dataset works on a whole column of your history (the statistics behind a chart), Row + dataset works in both.
  • Example — copy it, swap the field names for your own.

Two rules apply to every function on this page and are worth reading once: gaps are skipped, never counted as zero, and a calculation with nothing to work on comes back empty rather than erroring. Both are explained in The expression language.

43 functions, generated straight from the engine — if it is listed here, it works.

Logic

Branching and emptiness checks.

FunctionGives backScopeWhat it doesExample
empty(value?)boolean, or the empty value with no argumentRow + datasetTests whether a value is empty; called with no argument it yields the empty value itselfif(empty(prop("Notes")), "No notes", prop("Notes"))
if(condition, then, otherwise)anyRow + datasetPicks one of two values depending on a condition; the untaken branch is never evaluatedif(prop("Steps") > 10000, "Great day", "Keep going")

Math

Arithmetic helpers that work on single numbers (or durations).

FunctionGives backScopeWhat it doesExample
abs(value)numberRow + datasetThe absolute value of a number, dropping its signabs(prop("Weight") - prop("Target weight"))
ceil(value)numberRow + datasetRounds a number up to the nearest whole numberceil(prop("Sleep score"))
clamp(value, min, max)numberRow + datasetKeeps a number inside a range, pulling anything outside it to the nearest boundclamp(prop("Deep sleep"), 0, 60)
floor(value)numberRow + datasetRounds a number down to the nearest whole numberfloor(prop("Sleep score"))
max(value, …)number or durationRow + datasetThe largest of its arguments — all numbers, or all durations — or the largest sample of a single seriesmax(prop("Deep sleep"), prop("REM sleep"))
min(value, …)number or durationRow + datasetThe smallest of its arguments — all numbers, or all durations — or the smallest sample of a single seriesmin(prop("Deep sleep"), prop("REM sleep"))
round(value, digits?)numberRow + datasetRounds a number to the given number of decimal digits (0 by default)round(prop("Sleep score"), 1)

Text

Building and measuring text.

FunctionGives backScopeWhat it doesExample
concat(…)textRow + datasetJoins its arguments into one piece of text, with no separatorconcat(prop("First name"), " ", prop("Last name"))
length(text)numberRow + datasetThe number of characters in a piece of textlength(prop("Notes"))

Date & time

Reading the clock and the gap between two moments.

FunctionGives backScopeWhat it doesExample
dateBetween(later, earlier, unit)numberRow + datasetThe gap between two datetimes in "minutes", "hours" or "days"dateBetween(prop("Wake time"), prop("Bedtime"), "minutes")
now()datetimeRow + datasetThe current date and timedateBetween(now(), prop("Bedtime"), "hours")

Series

The opaque sample series a wearable records inside one entry — a night of heart-rate readings, say. Reduce one before you can compare or display it.

FunctionGives backScopeWhat it doesExample
seriesAvg(series)numberRow + datasetThe average of a series' samples, or empty when it has noneseriesAvg(prop("Heart rate"))
seriesCount(series)numberRow + datasetHow many non-empty samples a series holds; a missing series counts as zeroseriesCount(prop("Heart rate"))
seriesFractionAbove(series, threshold)numberRow + datasetThe share of a series' samples that sit above a threshold, from 0 to 1seriesFractionAbove(prop("Heart rate"), 120)
seriesFractionBelow(series, threshold)numberRow + datasetThe share of a series' samples that sit below a threshold, from 0 to 1seriesFractionBelow(prop("Heart rate"), 60)
seriesMax(series)numberRow + datasetThe highest of a series' samples, or empty when it has noneseriesMax(prop("Heart rate"))
seriesMin(series)numberRow + datasetThe lowest of a series' samples, or empty when it has noneseriesMin(prop("Heart rate"))

Descriptive

Summarising a whole column down to a single number.

FunctionGives backScopeWhat it doesExample
count(series)numberDatasetHow many values a column actually holds; gaps and a missing column count as zerocount(prop("Steps"))
mean(series)numberDatasetThe average of a column, ignoring gaps; empty when it has nothing to averagemean(prop("Steps"))
median(series)numberDatasetThe middle value of a column, ignoring gaps — the typical day when outliers would drag the averagemedian(prop("Bedtime hour"))
mode(series)numberDatasetThe most common value in a column, ignoring gaps; ties resolve to the lowest tied valuemode(prop("Wake hour"))
percentile(series, p)numberDatasetThe value a given percentage of a column sits below, with p from 0 to 100percentile(prop("Sleep score"), 90)
stddev(series)numberDatasetHow spread out a column is, as a sample standard deviation; empty below two valuesstddev(prop("Weight"))
sum(series)numberDatasetThe total of a column, ignoring gaps; empty when it holds nothingsum(prop("Calories"))
variance(series)numberDatasetThe sample variance of a column — the square of its standard deviation; empty below two valuesvariance(prop("Weight"))

Relational

How two columns relate, and how far a value sits from normal.

FunctionGives backScopeWhat it doesExample
corr(x, y)numberDatasetHow strongly two columns move together, from -1 to 1; rows missing either value are skippedcorr(prop("Sleep score"), prop("Steps"))
intercept(x, y)numberDatasetWhere the best-fit line through two columns crosses x = 0; rows missing either value are skippedintercept(prop("Day index"), prop("Weight"))
r2(x, y)numberDatasetHow much of y's variation the best-fit line explains, from 0 to 1 — the fit's trustworthinessr2(prop("Day index"), prop("Weight"))
slope(x, y)numberDatasetHow much y changes per unit of x on the best-fit line; rows missing either value are skippedslope(prop("Day index"), prop("Weight"))
zscore(series)seriesDatasetRestates a column in standard deviations from its own average; an all-equal column becomes zeroszscore(prop("Recovery"))

Sequence

Column in, column out — same length, gaps left where they were, so results stay row-aligned.

FunctionGives backScopeWhat it doesExample
cumsum(series)seriesDatasetThe running total of a column; a gap stays a gap but the total carries across itcumsum(prop("Distance"))
delta(series)seriesDatasetThe row-over-row change in a column; the first row, and either side of a gap, is emptydelta(prop("Weight"))
lag(series, offset)seriesDatasetShifts a column n rows later, so a row can be compared with the one n before it; the first n are emptylag(prop("Sleep score"), 1)
longestGap(series)numberDatasetThe longest unbroken run of false anywhere in a column, where non-zero is true and zero or empty is falselongestGap(prop("Hit protein goal"))
longestStreak(series)numberDatasetThe longest unbroken run of true anywhere in a column, where non-zero is true and zero or empty is falselongestStreak(prop("Hit protein goal"))
rollingAvg(series, window)seriesDatasetA trailing moving average over the last n rows; the first n-1 rows are empty, never a part-windowrollingAvg(prop("Weight"), 7)
rollingSum(series, window)seriesDatasetA trailing moving total over the last n rows; the first n-1 rows are empty, never a part-windowrollingSum(prop("Calories"), 7)
streak(series)numberDatasetThe current unbroken run of true at the end of a column, where non-zero is true and zero or empty is falsestreak(prop("Hit protein goal"))

Shaping

Rescaling and bucketing, for histograms and side-by-side comparison.

FunctionGives backScopeWhat it doesExample
bucket(value, width)numberRow + datasetSnaps a number down to the start of its band, for histogram-style groupingbucket(prop("Weight"), 5)
coalesce(value, …)anyRow + datasetThe first of its arguments that is not empty, or empty when they all arecoalesce(prop("Notes"), "No notes")
normalize(series)seriesDatasetRescales a column to 0..1 between its own lowest and highest values; an all-equal column becomes zerosnormalize(prop("Steps"))

Not on this list

Operators aren't functions, so they don't appear above — but + - * / %, == != < <= > >=, and and / or / not all work, and prop("Field name") is how you reference your data. See The expression language.

If a function you want isn't here, it doesn't exist yet — there's no hidden list. Ask the assistant what you're trying to work out and it will build it from the pieces above, or tell you it can't.

Next