Skip to main content
Formulas in Kodexa allow you to perform calculations, manipulate strings, work with dates, and make logical decisions. They can reference attributes from your taxonomy, perform complex calculations, and conditionally format or validate data.

Basic Syntax

Simple Expressions

Attribute References

Reference attributes from your data objects using curly braces:

Parent Navigation

Access parent data object attributes using ../:

Attribute Expressions (Filtering)

Filter attribute values using property expressions:

Comparison Operators

Logical Operators

Mathematical Functions

sum

Add multiple values together.

sumabs

Sum of absolute values.

average

Calculate the mean of values.

max

Find the maximum value.

min

Find the minimum value.

count

Count the number of items.

abs

Get absolute value (remove negative sign).

ceil

Round up to nearest integer.

floor

Round down to nearest integer.

round

Round to nearest integer.

decimalplaces

Round to a specific number of decimal places with optional rounding mode.
Rounding modes:
  • round_up - Round away from zero
  • round_down - Round towards zero
  • round_ceil - Round towards positive infinity
  • round_floor - Round towards negative infinity
  • round_half_up - Round half values up
  • round_half_down - Round half values down
  • round_half_even - Banker’s rounding (round to nearest even)
  • round_half_ceil - Round half values towards positive infinity
  • round_half_floor - Round half values towards negative infinity

stddeviation

Calculate standard deviation of values.

Empty group references

When an aggregate function receives a group reference that resolves to zero instances — e.g. sum({Accessorials/ChargeAmount}) against a shipment whose accessorial line items have all been deleted — the reference resolves to an empty list and the function computes accordingly: Formulas that watch a parent and aggregate over a child group therefore re-evaluate to the empty-list result when the last child row is removed, instead of preserving the previous total. The recalculator persists this — a sum whose group has just been emptied is rewritten to 0 rather than leaving the prior figure on screen. This applies only when the final path segment resolves to an empty list. Aggregates over a group that doesn’t exist at all (the taxon was never defined) still surface as a missing-reference error in the formula explain panel; aggregates that hit a runtime/syntax error preserve the previous value so transient failures don’t blank legitimate output.

String Functions

concat

Combine multiple strings into one.

uppercase

Convert text to uppercase.

lowercase

Convert text to lowercase.

trim

Remove leading and trailing whitespace.

substring

Extract part of a string.

length / strlen

Get the length of a string.

len

Get the length of a string or count array items.

contains

Check if a string contains a substring.

startswith

Check if a string starts with a substring.

endswith

Check if a string ends with a substring.

replace

Replace text within a string.

split

Split a string into an array by delimiter.

regex

Test if a string matches a regular expression pattern.

Date Functions

datemath

Add or subtract time from a date.

daysbetween

Calculate days between two dates.

weeksbetween

Calculate weeks between two dates.

monthsbetween

Calculate months between two dates.

isbeforedate

Check if first date is before second date (ignores time).

isafterdate

Check if first date is after second date (ignores time).

isdate

Check if a string is a valid date.

validatedate

Validate a date string (similar to ISDATE).

formatdate

Format a date string (specific format depends on implementation).

Logical Functions

if

Conditional logic - returns second parameter if condition is true, third if false.

isnull

Check if a value is null or empty.

ifnull

Return first parameter if not null, otherwise return second parameter.

ifblank

Return the first non-blank parameter, checking each in order. Unlike ifnull, empty strings and whitespace-only values also count as blank and fall through to the next parameter. If every parameter is blank, returns an empty string. Provide a single fallback or chain several.

isblank

Check if a value is blank/empty.

Advanced Array Functions

sumifs

Sum values that meet specific criteria (conditional sum).

countifs

Count values that meet specific criteria (conditional count).

Special Functions

confidence

Calculate confidence level (statistical function).

Complex Formula Examples

Multi-Condition Validation

This formula counts how many attribute pairs don’t match, useful for data validation.

Hierarchical Data Access

Builds a composite identifier from multiple levels of the data hierarchy.

Conditional Formatting

Formats output differently based on value thresholds.

Date Range Validation

Checks if a date falls within a range.

Best Practices

1. Use Parentheses for Clarity

2. Reference Attributes Correctly

3. Handle Null Values

4. Use Appropriate Functions

5. Test Complex Formulas Incrementally

Build up complex formulas step by step:
  1. {revenue}
  2. {revenue} - {costs}
  3. ({revenue} - {costs}) / {revenue}
  4. decimalplaces(({revenue} - {costs}) / {revenue} * 100, 2)

Troubleshooting

Common Issues

Attribute Not Found
  • Ensure attribute name matches taxonomy exactly
  • Check attribute path for hierarchical references
  • Verify attribute exists in current context
Type Mismatches
  • Can’t perform math on strings: "10" + 5 won’t work
  • Convert types explicitly when needed
  • Use appropriate functions for data types
Parent Navigation Errors
  • Parent data object not found - trying to go up too many levels
  • Check data object hierarchy depth
  • Ensure parent relationships exist
Date Format Issues
  • Use consistent date formats
  • ISO format (YYYY-MM-DD) is most reliable
  • Test with isdate() before date operations

Formula Evaluation Context

Formulas are evaluated with:
  • Current taxon - The taxonomy node being evaluated
  • Current data object - The data object containing attribute values
  • All data objects - For hierarchical navigation and aggregations
  • Taxonomy - For resolving attribute paths and types

Selection Option Formulas

Compute dropdown options dynamically using JavaScript formulas and service bridges

Validation and Conditional Formatting

Apply formulas to validation rules, exceptions, and review UI formatting

Event Subscriptions

Attach reactive scripts to group taxons that trigger when attributes change

Scripting Reference

Complete API reference for the GoJA JavaScript runtime used in formulas, scripts, and event subscriptions

Service Bridges in Scripts

Call external APIs from scripts via the service bridge proxy