JQXL Syntax Reference

jq pipelines + Excel formula helpers -- the expression language for computed fields in Boxel

See also BFM v3 Syntax Guide -- the document format that uses JQXL for formulas, inline transforms, and table queries.

field paths jq builtins Excel formulas operators variables strings

Core Mental Model

If you know spreadsheets, you know the core idea. The difference: instead of cell references like A1:B10, you work with JSON -- fields, arrays, and objects.

SpreadsheetJQXL
Cell valueJSON scalar (number, string, boolean)
Range A1:A10JSON array [1, 2, 3, ...]
Table with headersArray of objects [{name, age}, ...]
Current row. (the dot -- current JSON value)
=A1 + B1.price + .tax
=SUM(A1:A10)SUM(.items | map(.amount))
=IFERROR(A1, 0)IFERROR(.value; 0)
Arguments use semicolons ; not commas -- this is jq syntax. ROUND(.x; 2) not ROUND(.x, 2).
Array literals use commas: [1, 2, 3]. If a function call with semicolons is nested inside [...], bind it first: LEFT(.x; 1) as $v | SWITCH([$v, "A", "Alpha"]).

Core Dot Paths & Navigation

Basic Access

ExpressionResult
.
The entire current value (like "this row")
.name
Value of the name field
.patient.name
Nested field access
.orders[0]
First element of the orders array
.orders[-1]
Last element
.orders[2:5]
Slice: elements at index 2, 3, 4

Safe Access & Fallbacks

ExpressionMeaning
.owner?.email
Optional access -- no error if owner is null
.owner?.email // "none"
Alternative operator -- fallback if null/missing
.items[]
Iterate: emit each element as a separate value
..
Recursive descent -- all values at every depth

Core Pipes & Transforms

The pipe | chains operations left-to-right. Each step feeds its output to the next.

map, select, sort

Transform every element
.lineItems | map(.qty * .unitPrice)
Filter by condition
.orders | map(select(.status == "paid"))
Sort and reverse
.orders | sort_by(.placedAt) | reverse
Deduplicate
.tags | map(ascii_downcase) | unique | sort

group_by, flatten, add

Group and count
.orders
| group_by(.region)
| map({ region: .[0].region, count: length })
Flatten nested arrays
.departments | map(.employees) | flatten
Sum an array
.scores | add

Operators

OperatorMeaningExample
|Pipe.items | map(.x)
,Both outputs.a, .b emits two values
+ - * / %Arithmetic.price * .qty
== != < <= > >=Comparison.age >= 18
and or notLogical.a and .b
//Alternative (fallback).x // 0
= |= += -=Update.count += 1

Core Constructing Values

Objects

ExpressionResult
{id, status, total}
Shorthand -- pulls fields from current value
{patient: .patientName, ward: .ward}
Renamed fields

Arrays

ExpressionResult
[.name, .ward, .diagnosis]
Array from specific fields
[.items[] | .name]
Collect iterated values into array

String Interpolation

"Patient: \(.firstName) \(.lastName)"
Embed computed values in strings

Core Bindings & Variables

Use as $name to capture intermediate values. Avoids repeating complex sub-expressions.

Bind and reuse
(.items | map(.qty * .price) | add) as $subtotal
| {
    subtotal: $subtotal,
    tax: ROUND($subtotal * 0.0825; 2),
    total: ROUND($subtotal * 1.0825; 2)
  }
Tip: When in doubt, bind it. $subtotal is clearer than repeating the pipeline three times, and safer than threading it through pipes that might break when edited later.

Core Control Flow

PatternSyntax
Conditionalif .x > 0 then "positive" elif .x == 0 then "zero" else "negative" end
Try/catchtry (.x / .y) catch "division error"
Reducereduce .items[] as $i (0; . + $i.amount)
Foreachforeach .items[] as $i (0; . + $i.amount)
Define functiondef double: . * 2; .values | map(double)
Label/breaklabel $out | foreach .[] as $x (0; .+$x; if .>100 then ., break $out else . end)

Formula Math & Rounding

FunctionDescriptionExample
ROUND(n; d)Round to d decimal placesROUND(3.14159; 2) → 3.14
ROUNDUP(n; d)Round away from zeroROUNDUP(3.141; 2) → 3.15
ROUNDDOWN(n; d)Round toward zeroROUNDDOWN(3.149; 2) → 3.14
ABS(n)Absolute valueABS(-42) → 42
CEILING(n; s)Round up to significance (alias: CEILING_MATH)CEILING(2.3; 1) → 3
FLOOR(n; s)Round down to significance (alias: FLOOR_MATH)FLOOR(2.7; 1) → 2
INT(n)Floor to integerINT(3.9) → 3
MOD(a; b)Modulo (always non-negative)MOD(10; 3) → 1
POWER(n; p)ExponentiationPOWER(2; 10) → 1024
SQRT(n)Square rootSQRT(144) → 12
PRODUCT(arr)Product of all numbersPRODUCT([2, 3, 4]) → 24
PIConstant 3.14159...PI → 3.14159...
SIGN(n)Returns -1, 0, or 1SIGN(-42) → -1
EVEN(n)Round up to nearest evenEVEN(3) → 4
ODD(n)Round up to nearest oddODD(4) → 5
GCD(arr)Greatest common divisorGCD([12, 8, 20]) → 4
LCM(arr)Least common multipleLCM([4, 6, 10]) → 60
FACT(n)FactorialFACT(5) → 120
FACTDOUBLE(n)Double factorialFACTDOUBLE(7) → 105
COMBIN(n; k)CombinationsCOMBIN(10; 3) → 120
COMBINA(n; k)Combinations with repetitionCOMBINA(4; 2) → 10
PERMUT(n; k)PermutationsPERMUT(10; 3) → 720
MROUND(n; m)Round to nearest multipleMROUND(7.5; 3) → 9
QUOTIENT(n; d)Integer divisionQUOTIENT(7; 2) → 3
DEGREES(rad)Radians to degreesDEGREES(PI) → 180
RADIANS(deg)Degrees to radiansRADIANS(180) → 3.14159...
RANDRandom number 0--1RAND → 0.7291...
RANDBETWEEN(lo; hi)Random integer in rangeRANDBETWEEN(1; 100)
SUMPRODUCT(arrays)Sum of element-wise productsSUMPRODUCT([[1,2],[3,4]]) → 11
SUMSQ(arr)Sum of squaresSUMSQ([3, 4]) → 25

Formula Statistics

FunctionDescriptionExample
SUM(arr)Sum of numbers (skips nulls)SUM([10, 20, 30]) → 60
AVERAGE(arr)Mean (skips nulls)AVERAGE([10, 20, 30]) → 20
COUNT(arr)Count of finite numbersCOUNT([1, "a", 3]) → 2
COUNTA(arr)Count of non-blank valuesCOUNTA([1, "a", null]) → 2
MAX(arr)MaximumMAX([3, 1, 4]) → 4
MIN(arr)MinimumMIN([3, 1, 4]) → 1
STDEV(arr)Sample standard deviation (alias: STDEV_S)STDEV([2, 4, 4, 4, 5, 5, 7, 9])
STDEV_P(arr)Population standard deviationSTDEV_P([2, 4, 4, 4, 5, 5, 7, 9])
MEDIAN(arr)Middle valueMEDIAN([1, 3, 5, 7]) → 4
VAR(arr)Sample variance (alias: VAR_S)VAR([2, 4, 4, 4, 5, 5, 7, 9])
VAR_P(arr)Population varianceVAR_P([2, 4, 4, 4, 5, 5, 7, 9])
LARGE(arr; k)Kth largestLARGE([3, 1, 4, 1, 5]; 2) → 4
SMALL(arr; k)Kth smallestSMALL([3, 1, 4, 1, 5]; 2) → 1
COUNTBLANK(arr)Count of empty/null valuesCOUNTBLANK([1, null, "", 3]) → 2
RANK_EQ(n; arr)Rank (descending)RANK_EQ(4; [5, 4, 3, 2]) → 2
RANK_AVG(n; arr)Rank with average for tiesRANK_AVG(4; [5, 4, 4, 2]) → 2.5
PERCENTILE_INC(arr; k)Percentile (inclusive)PERCENTILE_INC([1,2,3,4]; 0.75) → 3.25
QUARTILE_INC(arr; q)Quartile (0--4)QUARTILE_INC([1,2,3,4]; 1) → 1.75
CORREL(x; y)Correlation coefficientCORREL([1,2,3]; [2,4,6]) → 1
SLOPE(y; x)Linear regression slopeSLOPE([2,4,6]; [1,2,3]) → 2
INTERCEPT(y; x)Linear regression interceptINTERCEPT([2,4,6]; [1,2,3]) → 0
FORECAST(x; y; knownX)Linear predictionFORECAST(4; [2,4,6]; [1,2,3]) → 8
GEOMEAN(arr)Geometric meanGEOMEAN([2, 8]) → 4
HARMEAN(arr)Harmonic meanHARMEAN([2, 8]) → 3.2
TRIMMEAN(arr; pct)Mean excluding outliersTRIMMEAN([1,2,3,4,100]; 0.4)
AVEDEV(arr)Average absolute deviationAVEDEV([2, 4, 8, 16])
DEVSQ(arr)Sum of squared deviationsDEVSQ([2, 4, 8, 16])
SKEW(arr)Distribution skewnessSKEW([1, 2, 3, 4, 100]) → positive
KURT(arr)Distribution kurtosisKURT([1, 2, 3, 4, 100]) → heavy-tailed
MAXIFS([vals; range; crit])Conditional maxMAXIFS([[5,3,8]; [1,2,1]; 1]) → 8
MINIFS([vals; range; crit])Conditional minMINIFS([[5,3,8]; [1,2,1]; 1]) → 5
PERCENTILE_EXC(arr; k)Percentile (exclusive)PERCENTILE_EXC([1,2,3,4,5]; 0.4)
QUARTILE_EXC(arr; q)Quartile exclusive (1--3)QUARTILE_EXC([1,2,3,4,5]; 1)
PERCENTRANK_INC(arr; x)Percentile rank (inclusive)PERCENTRANK_INC([1,2,3,4]; 3) → 0.667
PERCENTRANK_EXC(arr; x)Percentile rank (exclusive)PERCENTRANK_EXC([1,2,3,4]; 3) → 0.6
PEARSON(x; y)Pearson correlation (alias for CORREL)PEARSON([1,2,3]; [2,4,6]) → 1
SUM and AVERAGE automatically skip nulls and non-numeric values, just like their spreadsheet counterparts.

Formula Conditional Aggregation

Two flavors: range-based (classic Excel) and _BY variants for arrays of objects.

Range-Based (Classic)

FunctionDescription
SUMIF(range; criteria)Sum where criteria matches
SUMIF(range; criteria; sumRange)Sum from a different range
COUNTIF(range; criteria)Count where criteria matches
AVERAGEIF(range; criteria)Average where criteria matches

Row-Object Variants (_BY)

FunctionExample
SUMIF_BY(rows; valueKey; criteriaKey; criteria)SUMIF_BY(.; "amount"; "region"; "East")
SUMIFS_BY(rows; valueKey; criteriaObj)SUMIFS_BY(.; "amount"; {region: "East", team: "A"})
COUNTIF_BY(rows; criteriaKey; criteria)COUNTIF_BY(.; "status"; "active")
COUNTIFS_BY(rows; criteriaObj)COUNTIFS_BY(.; {region: "East", team: "A"})
AVERAGEIF_BY(rows; valueKey; criteriaKey; criteria)AVERAGEIF_BY(.; "score"; "grade"; "A")
AVERAGEIFS_BY(rows; valueKey; criteriaObj)AVERAGEIFS_BY(.; "score"; {grade: "A"})
Criteria strings support prefixes: =, <>, >, >=, <, <=. Wildcards: * (any chars), ? (single char). Escape with ~.

Formula Lookups

FunctionDescription
VLOOKUP(val; table; colIdx)Vertical lookup -- search first column, return nth column
VLOOKUP(val; table; colIdx; rangeLookup)Set rangeLookup to false for exact match
VLOOKUP_BY(rows; lookupKey; val; resultKey)Row-object VLOOKUP
HLOOKUP(val; table; rowIdx)Horizontal lookup
LOOKUP(val; lookupArr; resultArr)Simple lookup with two arrays
LOOKUP_BY(rows; lookupKey; val; resultKey)Row-object LOOKUP
MATCH(val; arr; matchType)Position of match (1-based). matchType: 1, 0, or -1
INDEX(arr; row)Value at position
INDEX(arr; row; col)Value at row and column
CHOOSE(idx; options)Select from list by 1-based index
COL(rows; key)Extract column values from array of objects
VLOOKUP_BY example
VLOOKUP_BY(.; "label"; "ventilator"; "amount")
INDEX + MATCH pattern
INDEX(.names; MATCH("target"; .ids; 0))

Formula Text

FunctionDescriptionExample
TEXTJOIN(delim; skipEmpty; arr)Join with delimiterTEXTJOIN(", "; true; .names)
CONCAT(arr)Concatenate array values (alias: CONCATENATE)CONCAT(["a", "b"]) → "ab"
LEFT(text; n)First n charactersLEFT("Hello"; 3) → "Hel"
RIGHT(text; n)Last n charactersRIGHT("Hello"; 2) → "lo"
MID(text; start; n)Substring (1-based)MID("Hello"; 2; 3) → "ell"
LEN(text)String lengthLEN("Hello") → 5
UPPER(text)UppercaseUPPER("hi") → "HI"
LOWER(text)LowercaseLOWER("HI") → "hi"
PROPER(text)Title CasePROPER("hello world") → "Hello World"
TRIM(text)Trim + collapse spacesTRIM(" hi there ") → "hi there"
SUBSTITUTE(text; old; new)Replace all occurrencesSUBSTITUTE("aaa"; "a"; "b") → "bbb"
SUBSTITUTE(text; old; new; n)Replace nth occurrenceSUBSTITUTE("aaa"; "a"; "b"; 2) → "aba"
REPLACE(text; pos; len; new)Replace by positionREPLACE("Hello"; 1; 2; "Ya") → "Yallo"
REPT(text; n)RepeatREPT("ab"; 3) → "ababab"
FIND(find; within)Case-sensitive position (1-based)FIND("lo"; "Hello") → 4
SEARCH(find; within)Case-insensitive positionSEARCH("LO"; "Hello") → 4
EXACT(a; b)Case-sensitive equalityEXACT("Hi"; "hi") → false
CHAR(n)Code point to character (alias: UNICHAR)CHAR(65) → "A"
CODE(text)First char to code point (alias: UNICODE)CODE("A") → 65
CLEAN(text)Remove control charsStrips 0x00-0x1F
VALUE(text)Parse string as numberVALUE("42") → 42
NUMBERVALUE(text; dec; grp)Locale-aware parsingNUMBERVALUE("1.234,56"; ","; ".")

Formatting Helpers

FunctionDescriptionExample
TEXT(val; fmt)Format number as stringTEXT(.date; "yyyy-mm-dd")
DOLLAR(n; d)Format as currencyDOLLAR(1234.5; 2) → "$1,234.50"
FIXED(n; d; noCommas)Fixed decimal stringFIXED(1234.5; 2; false) → "1,234.50"

Formula Logic & Type Checking

Conditionals

FunctionDescriptionExample
IF(test; then; else)Excel-style conditionalIF(.score >= 90; "A"; "B")
IFERROR(val; fallback)Catch any errorIFERROR(.x / .y; 0)
IFNA(val; fallback)Catch only #N/AIFNA(VLOOKUP(...); "missing")
IFS(c1; v1; c2; v2; ...)Multiple conditions (2--4 pairs)IFS(.x > 90; "A"; .x > 80; "B"; true; "C")
SWITCH([expr, v1, r1, ...])Value-based dispatch (commas inside array)SWITCH([.status, "A", "Active", "I", "Inactive", "Unknown"])

Boolean Functions

FunctionDescription
TRUELiteral true
FALSELiteral false
NAProduce #N/A error (use as sentinel)
NOT(val)Boolean NOT
AND(arr)All truthy (skips nulls/strings)
OR(arr)Any truthy (skips nulls/strings)
XOR(arr)Odd count of truthy values

Type Checking & Error Detection

FunctionDescription
ISBLANK(val)True if null/undefined
ISNUMBER(val)True if finite number
ISTEXT(val)True if string
ISERROR(val)True if any error
ISNA(val)True if #N/A error
ISERR(val)True if error but not #N/A
TYPE(val)Returns 1 (num), 2 (str), 4 (bool), 16 (error), 64 (array)
N(val)Convert to number (1/0 for bool)
T(val)Return string or ""
ERROR_TYPE(val)Error type code (1--8)
ISEVEN(val)True if even integer
ISODD(val)True if odd integer
ISLOGICAL(val)True if boolean
ISNONTEXT(val)True if not a string

Formula Date

Formula Helpers

FunctionDescription
DATE(year; month; day)Build Excel date serial number
DAY(date)Day of month (1--31)
MONTH(date)Month (1--12)
YEAR(date)Year
YEARFRAC(start; end; basis)Fraction of year between dates (basis 0--4)
DAYS(end; start)Days between two date serials
TODAYCurrent date as Excel serial number
HOUR(serial)Hour component (0--23)
MINUTE(serial)Minute component (0--59)
SECOND(serial)Second component (0--59)
WEEKDAY(serial; type)Day of week (type 1: Sun=1..Sat=7)
ISOWEEKNUM(serial)ISO week number
EDATE(start; months)Date offset by N months
EOMONTH(start; months)End of month, offset by N months
DATEDIF(start; end; unit)Difference in "Y", "M", "D", "MD", "YM", "YD"
DATEVALUE(text)Parse date string to serial number
DAYS360(start; end; method)Days on 360-day year (US/European)
WEEKNUM(serial; type)Week number (type 1: Sun start, 2: Mon start)
NETWORKDAYS(start; end; holidays)Business days between dates
WORKDAY(start; days; holidays)Date offset by N business days
TIME(hour; min; sec)Time as fraction of day
TIMEVALUE(text)Parse time string ("14:30") to fraction

jq Date Functions

FunctionDescription
nowCurrent Unix timestamp
strptime(fmt)Parse date string
strftime(fmt)Format timestamp
mktimeBroken-down time to Unix timestamp
gmtimeUnix timestamp to UTC time array
todateTimestamp to ISO-8601 string
fromdateISO-8601 string to timestamp
Date difference in days
((.endDate | strptime("%Y-%m-%d") | mktime)
 - (.startDate | strptime("%Y-%m-%d") | mktime)) / 86400

Formula Financial

Time Value of Money

FunctionDescription
PMT(rate; nper; pv; fv; type)Payment per period
IPMT(rate; per; nper; pv; fv; type)Interest portion of payment
PPMT(rate; per; nper; pv; fv; type)Principal portion of payment
FV(rate; nper; pmt; pv; type)Future value
PV(rate; nper; pmt; fv; type)Present value
NPER(rate; pmt; pv; fv; type)Number of periods
RATE(nper; pmt; pv; fv; type; guess)Interest rate per period
FVSCHEDULE(principal; schedule)FV with variable rates

Investment Analysis

FunctionDescription
NPV(rate; values)Net present value
NPV_BY(rate; rows; valueKey)NPV from row objects
IRR(values; guess)Internal rate of return
IRR_BY(rows; valueKey; guess)IRR from row objects
MIRR(values; finRate; reinRate)Modified IRR
XNPV(rate; values; dates)NPV for irregular cash flows
XNPV_BY(rate; rows; valKey; dateKey)XNPV from row objects
XIRR(values; dates; guess)IRR for irregular cash flows
XIRR_BY(rows; valKey; dateKey; guess)XIRR from row objects

Other Financial

FunctionDescription
CUMIPMT(rate; nper; pv; start; end; type)Cumulative interest between periods
CUMPRINC(rate; nper; pv; start; end; type)Cumulative principal between periods
EFFECT(nominal; npery)Effective annual rate
NOMINAL(effective; npery)Nominal annual rate
SLN(cost; salvage; life)Straight-line depreciation
SYD(cost; salvage; life; per)Sum-of-years depreciation
ACCRINT(issue; first; settle; rate; par; freq)Accrued interest
DB(cost; salvage; life; period; month)Declining balance depreciation
DDB(cost; salvage; life; period; factor)Double declining balance
ISPMT(rate; per; nper; pv)Interest for straight-line payments
PDURATION(rate; pv; fv)Periods to reach target value
RRI(nper; pv; fv)Required rate of return
DOLLARDE(frac; denom)Fractional dollar to decimal
DOLLARFR(dec; denom)Decimal dollar to fractional
DISC(settle; maturity; pr; redemption; basis)Discount rate of a security
PRICEDISC(settle; maturity; disc; redemption; basis)Price of discounted security
COUPDAYS(settle; maturity; freq; basis)Days in coupon period
TBILLEQ(settle; maturity; discount)T-bill bond-equivalent yield
TBILLPRICE(settle; maturity; discount)T-bill price per $100
TBILLYIELD(settle; maturity; price)T-bill yield
Monthly car payment
PMT(0.065 / 12; 60; 25000; 0; 0)
Project NPV
NPV(0.08; [-40000, 8000, 9200, 10000, 12000])

Formula Engineering

Base Conversion

FunctionDescription
BIN2DEC / DEC2BINBinary ↔ Decimal
BIN2HEX / HEX2BINBinary ↔ Hex
BIN2OCT / OCT2BINBinary ↔ Octal
DEC2HEX / HEX2DECDecimal ↔ Hex
DEC2OCT / OCT2DECDecimal ↔ Octal
OCT2HEX / HEX2OCTOctal ↔ Hex
BASE(n; radix; minLen)Arbitrary base conversion
DECIMAL(text; radix)Parse from arbitrary base

Bitwise Operations

FunctionDescription
BITAND(a; b)Bitwise AND
BITOR(a; b)Bitwise OR
BITXOR(a; b)Bitwise XOR
BITLSHIFT(n; shift)Left shift
BITRSHIFT(n; shift)Right shift

Complex Numbers

FunctionDescription
COMPLEX(real; imag; suffix)Construct complex number string
IMABS(val)Modulus
IMREAL(val)Real part
IMAGINARY(val)Imaginary part
IMCONJUGATE(val)Complex conjugate
IMSUB(a; b)Complex subtraction
IMSUM(values)Complex sum
DELTA(a; b)1 if equal, 0 otherwise
GESTEP(n; step)1 if ≥ step, 0 otherwise
IMCOS(z)Complex cosine
IMSIN(z)Complex sine
IMTAN(z)Complex tangent
IMEXP(z)Complex exponential
IMLN(z)Complex natural log
IMLOG10(z)Complex log base 10
IMLOG2(z)Complex log base 2
IMDIV(a; b)Complex division
IMPRODUCT(values)Complex product
IMPOWER(z; n)Complex power
IMSQRT(z)Complex square root
IMARGUMENT(z)Angle (argument) of complex number
ERF(lower; upper)Error function (Gauss)
ERFC(x)Complementary error function
CONVERT(n; from; to)Unit conversion (120+ units, SI prefixes)
CONVERT examples
CONVERT(1; "mi"; "km")       // 1.609344
CONVERT(100; "C"; "F")       // 212
CONVERT(1; "gal"; "L")      // 3.785...
CONVERT(1; "kg"; "lbm")    // 2.204...
CONVERT(1024; "byte"; "kibyte") // 1 (binary prefix)

Boxel Computed Fields

In Boxel, JQXL expressions live inside computeVia on a field definition. The field type acts as the output contract.

Basic pattern
import { expression } from './jqxl';

@field total = contains(NumberField, {
  computeVia: expression('ROUND(.subtotal * (1 + .taxRate); 2)'),
});
Structured result
@field summary = contains(SummaryField, {
  computeVia: expression(`
    (.items | map(.qty * .price) | add) as $sub
    | {
        subtotal: $sub,
        tax: ROUND($sub * 0.0825; 2),
        total: ROUND($sub * 1.0825; 2)
      }
  `, { as: SummaryField }),
});
Array result
@field alerts = containsMany(AlertField, {
  computeVia: expression(`
    .issues
    | map(select(.severity == "high"))
    | map({ label: .title, owner: (.owner.name // "unassigned") })
  `, { as: AlertField }),
});

Field Type → Expression Return Type

Field DeclarationExpression Must Return
contains(NumberField)A number
contains(StringField)A string
contains(BooleanField)A boolean
contains(SomeFieldDef)An object matching the FieldDef shape
containsMany(NumberField)An array of numbers
containsMany(SomeFieldDef)An array of objects

Chaining Computed Fields

One field references another
@field subtotal = contains(NumberField, {
  computeVia: expression('.lineItems | map(.qty * .unitPrice) | add'),
});

@field total = contains(NumberField, {
  computeVia: expression('ROUND(.subtotal * 1.0825; 2)'),
});
Computed fields can reference other computed fields on the same card. Each field is one step -- explicit, testable, and easy to trace.

Reading Across Relationships

ExpressionWhat it does
.attendingClinician.name
Read a field from a linked card
.consultTeam | map(.name)
Map over a linksToMany relationship
.patient.firstName + " " + .patient.lastName
Concatenate across a link

Boxel jq Builtins Index

Complete index of core jq functions available in JQXL.

Array / Object

FunctionDescription
lengthLength of string/array/object
keys / keys_unsortedSorted / unsorted keys
has(key)Test if key/index exists
contains(v)Deep containment check
in(obj)Test if input is key in obj
inside(v)Test if input is contained in v
map(f)Apply f to each element
map_values(f)Apply f to all values
select(f)Keep elements where f is truthy
del(f)Delete paths
addSum/fold array
sort / sort_by(f)Sort array
reverseReverse array
unique / unique_by(f)Deduplicate
group_by(f)Group by key
min_by(f) / max_by(f)Extremes by key
flatten / flatten(n)Flatten to depth
join(sep)Join array to string
to_entriesObject to [{key, value}]
from_entries[{key, value}] to object
with_entries(f)Transform entries
transposeMatrix transpose
indices(v)All indices of v
index(v) / rindex(v)First / last index
range(n) / range(a;b)Number range
walk(f)Apply f to all nodes bottom-up
recurse(f)Recursive descent
paths / leaf_pathsAll / leaf paths
getpath(p) / setpath(p; v)Path access
pick(pathexps)Pick paths from input
ROWS(arr) / COLUMNS(arr)Row/column count

String

FunctionDescription
ascii_downcase / ascii_upcaseCase conversion
ltrimstr(s) / rtrimstr(s)Remove prefix / suffix
trim / ltrim / rtrimTrim whitespace
startswith(s) / endswith(s)Test prefix / suffix
split(s)Split on string
test(re) / match(re)Regex test / match
capture(re)Named capture groups
scan(re)All regex matches
sub(re; s) / gsub(re; s)Regex substitution
tostring / tonumberType conversion
tojson / fromjsonJSON encode/decode
explode / implodeString ↔ codepoints

Type Selectors

FunctionDescription
typeReturn type name as string
arrays / objects / strings / numbers / booleans / nullsSelect by type
values / scalarsNon-null / scalar values
iterablesArrays or objects
isnan / isinfinite / isnormal / isfiniteNumber predicates
nan / infiniteIEEE constants

Iteration & Flow

FunctionDescription
first / first(g)First element / output
last / last(g)Last element / output
nth(n; g)Nth output
limit(n; g)First n outputs
skip(n; g)Skip first n outputs
isempty(g)True if generator is empty
any / any(f) / any(g; f)Existential test
all / all(f) / all(g; f)Universal test
while(cond; update)Emit while condition holds
until(cond; next)Apply until condition holds
repeat(f)Repeat forever
combinationsCartesian product
emptyProduce no output

Math (jq native)

CategoryFunctions
Trigsin cos tan asin acos atan atan2(y)
Hyperbolicsinh cosh tanh asinh acosh atanh
Exp/Logexp exp2 exp10 log log2 log10 pow(y) sqrt cbrt
Roundingfloor ceil round trunc fabs
Otherhypot(y) fmax(y) fmin(y)

Boxel String Formats

Used as @fmt "..." or format("fmt") for string interpolation.

FormatDescriptionExample
@textConvert to string (default)42 | @text → "42"
@jsonJSON-encode{a:1} | @json → '{"a":1}'
@htmlHTML-escape"<b>" | @html → "&lt;b&gt;"
@uriPercent-encode"a b" | @uri → "a%20b"
@uridPercent-decode"a%20b" | @urid → "a b"
@csvCSV row["a","b"] | @csv → "\"a\",\"b\""
@tsvTSV row["a","b"] | @tsv → "a\tb"
@shShell-escape"it's" | @sh → "'it'\\''s'"
@base64Base64 encode"hello" | @base64
@base64dBase64 decode"aGVsbG8=" | @base64d

Boxel Error Codes

JQXL uses Excel-compatible error codes. Catch them with IFERROR, IFNA, or try/catch.

ErrorCodeMeaning
#NULL!1Null reference
#DIV/0!2Division by zero
#VALUE!3Wrong value type
#REF!4Invalid reference
#NAME?5Unknown function name
#NUM!6Numeric error (overflow, domain)
#N/A7Value not available
#GETTING_DATA8Data still loading
Handling errors
IFERROR(.revenue / .headcount; 0)

try (.x | tonumber) catch "not a number"

IF(ISERROR(.lookup); "fallback"; .lookup)

Boxel Excel Function Coverage

JQXL implements 230+ functions from the Excel/Google Sheets function set, plus 16 JQXL-only extensions (the _BY row-object variants). This section maps coverage against the formulajs library.

Available via jq (use lowercase)

These Excel functions are not implemented as uppercase helpers because jq already provides them natively. Use the lowercase jq version.

Exceljq equivalentCategory
SIN COS TANsin cos tanTrig
ASIN ACOS ATAN ATAN2asin acos atan atan2Trig
SINH COSH TANHsinh cosh tanhHyperbolic
ASINH ACOSH ATANHasinh acosh atanhHyperbolic
EXP LOG LOG10exp log log10Exp/Log
LNlog (jq's log is natural log)Exp/Log
TRUNCtruncRounding
SORTsort / sort_by(f)Array
UNIQUEunique / unique_by(f)Array
TRANSPOSEtransposeArray
NOWnow (Unix timestamp)Date
Range-based multi-criteria functions (SUMIFS, COUNTIFS, AVERAGEIFS) are not implemented as uppercase helpers because JQXL's _BY variants (SUMIFS_BY, COUNTIFS_BY, AVERAGEIFS_BY) are more natural for JSON data. Use those instead.

Won't Add

Functions that don't apply to JQXL's JSON context, require a spreadsheet grid model, or are too niche for document formulas.

CategoryFunctionsReason
DatabaseDAVERAGE DCOUNT DCOUNTA DGET DMAX DMIN DPRODUCT DSTDEV DSTDEVP DSUM DVAR DVARPExcel database functions assume a flat cell range with criteria ranges. JQXL uses map/select/_BY variants instead -- more powerful on JSON.
Grid referenceCOLUMN ROW SUBTOTAL AGGREGATERequire a cell grid model. No equivalent concept in JSON expressions.
MatrixMMULT MUNITMatrix multiplication and identity. Use jq array operations or dedicated math libraries.
DistributionsBETA.DIST BINOM.DIST CHISQ.DIST F.DIST GAMMA.DIST NORM.DIST POISSON.DIST T.DIST WEIBULL.DIST and all their .INV, .RT, .TEST variants53 statistical distribution functions. Too specialized for document formulas. Use a statistics library for serious analysis.
RegressionLINEST LOGEST GROWTH TRENDArray-returning regression functions. Complex output shapes don't map well to single computed fields.
BesselBESSELI BESSELJ BESSELK BESSELYHighly specialized engineering functions.
FormattingROMAN ARABICRoman numeral conversion. Extremely niche.
Other nicheSERIESSUM MULTINOMIAL SQRTPI SUMX2MY2 SUMX2PY2 SUMXMY2Specialized math. Expressible via jq pipelines.

Coverage Summary

StatusCountNotes
Implemented230+All targeted Excel-compatible formula functions
JQXL-only extensions16_BY row-object variants, COL, ERROR_TYPE
Available via jq23Trig, exp/log, sort, unique, transpose, now (use lowercase)
Won't add~80Database, distributions, grid-dependent, Bessel, regression arrays