C3 AI Documentation Home

Expression Engine Functions

The C3 Agentic AI Platform includes a library of functions that can be applied on simple and compound metrics, stored calc expressions, evaluation projections, and fetch filters. The library of functions is included in the Type ExpressionEngineFunction.

A complete list of the functions can be found by using the c3ShowType command on the ExpressionEngineFunction Type.

Common functions

CategoryExamples
Aggregationmin, max, avg, sum, and, or, count, median stddev, variance
Time series operationsrolling, window, eval, aggregate, available, linearDecay, exponentialDecay,fillMissing, interpolate, percentile, rollingDiff, rollup, scaleMinMax, scaleStandard, removeOutliers
Arithmeticceil, floor, round, abs, random, cos, acos, sin, asin, tan, atan, cuberoot, dotProduct, exp, log, pow, sqrt
String operationsconcat, contains, startsWith, endsWith, length, join, lowerCase, upperCase, matchCount, matchesRegex, findAll, replace, substring, split
Type castingstring, number, dateTime, book, data, convertToUnit
Time operationsdayOfWeek, daysInYear, earliest, latest, year, month, day, hour, minute, second, timeComponent, start, end, interval, period
Miscellaneousexists, not, intersects, unique, count, ascending, descending, haversineDistance, map, identity

Basic examples

CategoryExample
Aggregationavg(normalized.data.power)
Time series operationsrolling(AveragePower)
Arithmeticabs([1, -4.5, 9, -2312.2])
String operationscontains(name, 'Power')
Type castingdateTime('2020-01-01')
Time operationscount(id)
Miscellaneousearliest(normalized.data.power)

You cannot call an ExpressionEngineFunction directly such as:

JavaScript
ExpressionEngineFunction.dateTime("2023-01-01")

You can test these methods by calling them in the Expr.eval() function and execute the code in the C3 AI Console.

Here are some examples:

JavaScript
Expr.eval(`bit(23, 1)`); // returns true
Expr.eval(`bit(20, 1)`); // returns false
Expr.eval(`join("-", ["One", "Two"])`); // returns "One-Two"
Expr.eval(`compareTo("abc", "zyx")`); // returns -25
Expr.eval("findAll('Vowels are aeiou', '[a-f]+')");
Expr.eval(`dateTime("2023-01-01")`);
Expr.eval(`dateTime($DateTime.now())`);

See also

Expression Engine Functions:

JavaScript logical and numerical operators:

  • All operators as of ES5 are supported.

Metrics:

Was this page helpful?