🧮 Appendix A: Formula Reference

About Formulas

NetSuite saved searches support SQL-based formulas for calculated fields. Use formulas in both Criteria (filters) and Results (columns) to create custom calculations, text manipulation, and conditional logic.

Date Formulas

Days Since Date

{today} - {trandate}
Calculate days between today and transaction date.

Days Overdue

TRUNC({today}) - NVL({duedate}, {trandate})
Days past due date (uses transaction date if no due date).

Contract Age in Days

ABS({startdate} - NVL({canceldate}, {today}))
Days from start to cancel date (or today if not canceled).

Text Formulas

Concatenate Address

{city} || ', ' || {state} || ' ' || {zipcode}
Combine city, state, and zip into one field.

Extract Email Domain

SUBSTR({email}, INSTR({email}, '@') + 1)
Get domain portion of email address.

Conditional Formulas (CASE WHEN)

AR Aging Buckets

CASE WHEN TRUNC({today}) - NVL({duedate},{trandate}) BETWEEN 1 AND 30 THEN {fxamount} - {fxamountpaid} ELSE 0 END
Calculate amount in 1-30 days aging bucket.

Traffic Light Status

CASE WHEN {quantity} > 20 THEN 'Green' WHEN {quantity} > 10 THEN 'Yellow' ELSE 'Red' END
Color code based on quantity thresholds.

Markup Percentage

({price} - {cost}) / NULLIF({cost}, 0) * 100
Calculate markup % (handles divide by zero).

Common SQL Functions

FunctionPurposeExample
NVL(a, b)Return b if a is nullNVL({duedate}, {trandate})
NULLIF(a, b)Return null if a = bNULLIF({cost}, 0)
TRUNC(date)Remove time from dateTRUNC({today})
ABS(n)Absolute valueABS({balance})
ROUND(n, d)Round to d decimalsROUND({rate}, 2)
UPPER(s)Convert to uppercaseUPPER({name})
SUBSTR(s, start, len)Extract substringSUBSTR({phone}, 1, 3)
INSTR(s, find)Position of substringINSTR({email}, '@')
TO_CHAR(d, fmt)Format date as textTO_CHAR({trandate}, 'YYYY-MM')