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
| Category | Examples |
|---|---|
| Aggregation | min, max, avg, sum, and, or, count, median stddev, variance |
| Time series operations | rolling, window, eval, aggregate, available, linearDecay, exponentialDecay,fillMissing, interpolate, percentile, rollingDiff, rollup, scaleMinMax, scaleStandard, removeOutliers |
| Arithmetic | ceil, floor, round, abs, random, cos, acos, sin, asin, tan, atan, cuberoot, dotProduct, exp, log, pow, sqrt |
| String operations | concat, contains, startsWith, endsWith, length, join, lowerCase, upperCase, matchCount, matchesRegex, findAll, replace, substring, split |
| Type casting | string, number, dateTime, book, data, convertToUnit |
| Time operations | dayOfWeek, daysInYear, earliest, latest, year, month, day, hour, minute, second, timeComponent, start, end, interval, period |
| Miscellaneous | exists, not, intersects, unique, count, ascending, descending, haversineDistance, map, identity |
Basic examples
| Category | Example |
|---|---|
| Aggregation | avg(normalized.data.power) |
| Time series operations | rolling(AveragePower) |
| Arithmetic | abs([1, -4.5, 9, -2312.2]) |
| String operations | contains(name, 'Power') |
| Type casting | dateTime('2020-01-01') |
| Time operations | count(id) |
| Miscellaneous | earliest(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:
- Review the Time Series Reference.