Logo
NeoArc Studio

Expression Builder Guide

How to use the expression builder for complex property transformations. Covers field references, string functions, date functions, mathematical operations, CASE/WHEN conditional logic, and practical examples.

The expression builder allows you to create derived properties in projections. Instead of mapping a property directly from a single source field, you write an expression that combines, transforms, or conditionally selects values from one or more source fields. Expressions are evaluated during projection resolution to produce the final property value.

Field References

Expressions reference source fields using their names. When a property in the source entity is named firstName, you reference it as firstName in the expression. Nested references use dot notation: address.city.

String Functions

FunctionDescriptionExampleResult
CONCAT(a, b, ...)Join strings togetherCONCAT(firstName, ' ', lastName)John Smith
UPPER(s)Convert to uppercaseUPPER(status)ACTIVE
LOWER(s)Convert to lowercaseLOWER(email)[email protected]
TRIM(s)Remove leading and trailing whitespaceTRIM(name)John
SUBSTRING(s, start, length)Extract part of a stringSUBSTRING(postCode, 1, 3)SW1
REPLACE(s, find, replacement)Replace occurrences in a stringREPLACE(phone, '-', '')07712345678
LEFT(s, length)Extract characters from the startLEFT(reference, 4)ORD-
RIGHT(s, length)Extract characters from the endRIGHT(reference, 6)001234
LENGTH(s)Return the length of a stringLENGTH(description)42

Date Functions

FunctionDescriptionExample
YEAR(d)Extract the yearYEAR(createdAt)
MONTH(d)Extract the month (1-12)MONTH(publishedDate)
DAY(d)Extract the day of monthDAY(startDate)
DATE_DIFF(d1, d2, unit)Difference between two datesDATE_DIFF(endDate, startDate, 'days')
DATE_ADD(d, amount, unit)Add time to a dateDATE_ADD(createdAt, 30, 'days')
DATE_FORMAT(d, format)Format a date as a stringDATE_FORMAT(createdAt, 'YYYY-MM-DD')
NOW()Current date and timeDATE_DIFF(NOW(), lastLogin, 'days')

Mathematical Operations

OperationSyntaxExample
Additiona + bprice + tax
Subtractiona - bgrossAmount - discount
Multiplicationa * bquantity * unitPrice
Divisiona / btotalScore / questionCount
Moduloa % browNumber % 2
ROUND(n, decimals)Round to decimal placesROUND(price * taxRate, 2)
FLOOR(n)Round down to nearest integerFLOOR(averageRating)
CEIL(n)Round up to nearest integerCEIL(weight)
ABS(n)Absolute valueABS(balance)

CASE/WHEN Conditional Logic

Use CASE/WHEN expressions for conditional property values. This is similar to SQL CASE statements.

The syntax follows this pattern:

CASE
  WHEN condition1 THEN result1
  WHEN condition2 THEN result2
  ELSE defaultResult
END

Practical Examples

Derived PropertyExpressionPurpose
fullNameCONCAT(firstName, ' ', lastName)Combine name parts into a single display name
totalPricequantity * unitPriceCalculate line item total
discountedPriceROUND(price * (1 - discountRate), 2)Apply percentage discount with rounding
ageInDaysDATE_DIFF(NOW(), createdAt, 'days')Calculate how old a record is
displayStatusCASE WHEN isActive = true THEN 'Active' WHEN deletedAt IS NOT NULL THEN 'Deleted' ELSE 'Inactive' ENDHuman-readable status label
shortReferenceCONCAT(LEFT(UPPER(category), 3), '-', RIGHT(id, 6))Generate a short reference code
financialQuarterCONCAT('Q', CEIL(MONTH(transactionDate) / 3))Derive quarter from transaction date

Tips

Next Steps