Appearance
Expressions
Computed fields, showIf/validIf, onlyIf, initial values, and action updates are all written in the same formula language: a spreadsheet-style syntax with {field} references and a large built-in function library.
Writing a formula in the editor
Every place that takes a formula uses the same editor, so you only learn it once. It helps as you type:
- Function suggestions. Type two or more letters of a function name, in any case (
mult,MULT), and a list of matching functions appears. Press Tab to pick one and the editor writes it in capitals. Then type an opening bracket and the editor adds the closing one. - Field suggestions. Type
{and the list changes to the fields of the current collection. Pick one and the cursor lands after the closing brace, ready for the next value. - The hint bar. Just above the box, a bar shows the function you're inside and each value it expects. The value you're typing is highlighted, with a short description beside it.
- Live checks. The editor checks as you type. Red means the formula can't work: a bracket left open, or a function that doesn't exist. Orange means take a look: a function given fewer or more values than it usually takes, a field name that isn't on this collection, a unit or style that isn't one of the allowed words, or an
ENUMoption that isn't one of that field's options (the warning lists the real ones). - The full editor. For longer formulas, click the expand button in the box's corner. You get a bigger writing area and two reference panels: your fields with their types, and every function. The function search looks at names and descriptions, so typing
sumfindsSUMARRAY. Click Apply to send the formula back to the field.
Try a formula before you use it
Tools → Query Editor in the app admin evaluates a formula against your real data without saving or changing anything. Choose a collection and a record, type the formula, and click Evaluate (or press Ctrl+Enter). The result shows with a badge for its type: string, number, boolean, or null for a blank result. Try a formula here first, then paste it into the field, filter or card that needs it.
The Query Editor runs as the app's admin, so USERPROFILE("name") there returns the admin's name. A signed-in person in the app gets their own.
Referencing fields
{field}: a field on the current record.{ref.field}: traverse a reference field to read a field on the linked record (e.g.{product.name}). Chains of references work too:{shift.location.name}.{_THISRECORD.field}: inside a query condition, refers to the outer record the query was run from (as opposed to the candidate row currently being tested).{_PREVROW.field}/{_NEXTROW.field}: the previous/next row in a list pass.{_INDEX}/{_TOTAL}: the current position and total count in a list pass.{_FORM.field}: a value entered into aform_actiondialog.{_THISUser.field}: the logged-in user's own record (id, email, name, etc.).
Logic
IF(cond, then, else), IFS(cond1, val1, cond2, val2, ..., default), SWITCH(value, match1, result1, match2, result2, ..., default), AND, OR, NOT, EQUAL, GT, LT, GTE, LTE, ISBLANK, ISEMAIL (true when the text looks like an email address; a blank value is not one, so an optional field uses OR(ISBLANK({email}), ISEMAIL({email})); to refuse a typo everywhere, not only in the app's own forms, set the text field's Must be an email address option instead), and ROLE("name") (checks a role name against the app's configured roles, handy inside EQUAL(USERPROFILE("role"), ROLE("admin"))), and ENUM("collection", "field", "option") (the same check for an enum option, handy inside EQUAL({status}, ENUM("orders", "status", "packed")); the editor suggests the collection, then its enum fields, then that field's options, and warns if any of them is wrong).
There are no +, -, *, /, >=, && or || operators: everything is a function call (ADD, SUBTRACT, GTE, AND, …).
Text
CONCATENATE, JOIN, UPPER, LOWER, TRIM, LEN, LEFT, RIGHT, CONTAINS, REPLACE, NUMBERFORMAT, MONEYFORMAT.
NUMBERFORMAT(value, decimals?) writes a number with thousands separators: NUMBERFORMAT(124000) is 124,000. Leave decimals out and it keeps up to two and drops trailing zeros (1234.5 is 1,234.5); give it and you get exactly that many (NUMBERFORMAT(1234.5, 2) is 1,234.50, NUMBERFORMAT(1234.567, 0) is 1,235). MONEYFORMAT(value, currency?, decimals?) does the same with a currency sign: MONEYFORMAT(124000) is ₦124,000.00, MONEYFORMAT(1500, "USD") is $1,500.00, and a loss is written -₦3,000.00. The currency is a code such as NGN (the default), KES or GBP (MONEYFORMAT(1500, "KES", 0) is KSh 1,500). Both round halves away from zero like ROUND, give blank for something that is not a number, and return text, so format last: CONCATENATE("Profit: ", MONEYFORMAT(SUBTRACT({income}, {expenses}))) works, but you can't add up the formatted result. A price field and a home screen formula card already show their own formatting; these are for sentences, receipts and PDFs.
Math
ADD, SUBTRACT, MULTIPLY, DIVIDE, MOD, POWER, SQRT, ROUND, MROUND, CEILING, FLOOR, PERCENT (what part of the whole is done, 0 to 100), ABS, MIN, MAX, AVERAGE, DISTANCEBETWEEN (for two geolocation values), LATITUDE and LONGITUDE (the two numbers inside a geolocation value), ADDRESS (the city, state or country of an address value, or all of it as text).
Dates
NOW(), TODAY(), YESTERDAY(), TOMORROW(), TIMENOW(), DATE, TIME, DAYOFWEEK, STARTOFDAY, ENDOFDAY, STARTOFMONTH(), ENDOFMONTH(), STARTOFYEAR, ENDOFYEAR, YEAR, MONTH, DAY, HOUR, MINUTE, WEEKDAY, DATEDIFF, DATEADD, DATEFORMAT, TIMEFORMAT, ISBEFORE, ISAFTER, ISBETWEEN. Compare dates with ISBEFORE / ISAFTER / ISBETWEEN, not GT / LT.
Generating values
RAND(min?, max?), UNIQUEID() and UNIQUECHAR(type, length) produce fresh random values. UNIQUECHAR("alphanumeric", 6) gives a short random code, where type is letters, numeric, alphanumeric, special, or all. They generate a new value every time they're evaluated, so use them as a field's initial value (which runs once when the create form opens), never in a computed field. UNIQUECHAR is random, not guaranteed unique; use UNIQUEID() when a value must never repeat.
Cross-collection queries
These look at other records, not just the current one:
COLLECTIONSELECT("collection", "condition"): every record matching the condition.FILTER("collection", "condition"): same idea, lighter weight.REF_ROWS("collection", "foreignKey"): shorthand for the common reverse-lookup case: every record incollectionwhoseforeignKeyfield points back at this record. Equivalent toCOLLECTIONSELECT("collection", "EQUAL({foreignKey},{_THISRECORD.id})"). Takes an optional third argument,REF_ROWS("collection", "foreignKey", "extraCondition"), AND-ed onto the auto-generated equality check. Drop toCOLLECTIONSELECT/FILTERdirectly once you need anything beyond that (sorting, OR logic, multiple extra conditions).SELECT("collection", "returnColumn", "condition"): just the values of one column.EXISTS("collection", "condition"): true if any record matches.Filtering a list the record already has. In
FILTER,COLLECTIONSELECT,SELECT,EXISTS,ORDERBYandORDERBYDESCENDING, the first argument can be a{list field}instead of a quoted collection name. A completelist is a list of records; written in braces it is used as it is, with nothing read again, and the condition runs only over those rows. In the condition,{field}is a field of each row of the list and{_THISRECORD.field}is the record you are on:FILTER({tasks}, EQUAL({status}, "open")): the open ones, as a list you can show in another completelist field.COUNT(FILTER({tasks}, EQUAL({status}, "open"))): how many.SUMARRAY(SELECT({tasks}, "hours", EQUAL({status}, "open"))): their hours added up.EXISTS({tasks}, EQUAL({status}, "blocked")): is any blocked?ORDERBY({tasks}, "title", EQUAL({status}, "open"), "title"): their titles, in order.
A quoted name still means "read that collection", so existing formulas are unchanged. The braces tell the two apart. A list can be filtered again (
FILTER(FILTER({tasks}, …), …)). The field must be a list of records (a completelist); a text or number field gives nothing.COUNT(...),FIRST(...),LAST(...),SUMARRAY(...): operate on the array a query returns.COUNTalso works on a multi-select field:COUNT({symptoms})is how many options are ticked (0 for none). UseIN("bleeding", {symptoms})to test whether one option is among them. Both also work through a reference, e.g.COUNT({questionnaire.symptoms}).LOOKUP(value, "collection", "lookupColumn", "returnColumn"): single-value lookup.ORDERBY/ORDERBYDESCENDING: sorted query results.USERPROFILE("field"): a field from the current user's profile record.SETTINGS("field"): a field from the app's settings record, a value everyone shares, such as a commission rate or a business name:MULTIPLY({total}, DIVIDE(SETTINGS("vendor_percentage"), 100)). Mark one collection This holds the app's settings in the collection editor; it keeps exactly one record, which the app creates, and opens as a single form instead of a list. Everyone who is signed in can read it, so the formulas work for every role; on the role's permissions page its row has just one choice, Can edit, for who may change it. To keep a value from a role, hide that field for the role under Hidden fields (it then reads blank for them). It has no Create or Delete. It works anywhereUSERPROFILE()does, and a computed field that uses it follows the setting when it changes, so keep a value that must not change (a price on an old order) in a stored field, copied when the record is made.HERE(): the device's current geolocation.
Writing condition arguments
The condition argument of COLLECTIONSELECT / FILTER / EXISTS / SELECT / ORDERBY is evaluated per row. Write it as a plain expression, just like any other argument:
EXISTS("cartitem", EQUAL({product}, {_THISRECORD.product}))The older style of passing the condition as a quoted string (EXISTS("cartitem", "EQUAL({product}, {_THISRECORD.product})")) still works, but a quoted condition can't contain string literals of its own, so prefer the plain form.
For every function with its exact parameters, see the Schema Reference.
Special-purpose
IN(value, list): true ifvalueappears anywhere in an array.IFS(...): first matching condition wins; the trailing argument is the default.SWITCH(value, match1, result1, match2, result2, ..., default): compares one value with several options and gives the result of the first one that is equal; the trailing argument is the default, and with no match and no default the result is blank. Use it instead ofIFSwhenever you would repeatEQUAL({field}, ...)on the same field, for example to turn a status into a progress number:SWITCH({status}, "new", 10, "confirmed", 20, "washing", 40, "delivered", 100, "cancelled", 0, 0)It compares exactly as
EQUALdoes (the number1is not equal to the text"1"), and a blank value takes the default. When the value is a choice field of the same collection, the editor warns if a match is not one of its options, so a typo or a renamed option can't quietly fall through to the default.
Good to know
A few behaviours that are easy to trip over:
NOW()vsTODAY().NOW()is the exact moment, with the time, so it changes every second.TODAY()is the start of today (midnight), the same all day. UseTODAY()for anything measured in days, andNOW()only when the time of day matters.DATEDIFF(a, b, unit)isaminusb. Put the later date first:DATEDIFF(TODAY(), {date_created}, "days")is how many days ago a record was created. The other way round gives a negative number. The result is a whole number, with the fraction cut off. The unit isseconds,minutes,hours,days,weeks,monthsoryears.DATEADD(date, n, unit)takes the same units.DATEFORMAT(date, style)turns a date into readable text; the style islong(31 October 2026),short,monthoriso.TIMEFORMAT(date, style)does the same for the time of day:24h(the default,14:30) or12h(2:30 PM). It also reads a plain time like"14:30", soTIMEFORMAT({starts}, "12h")works on a time field.- Dividing can leave long decimals.
DIVIDE(8500, 3)is2833.3333333333335. Wrap it inROUND(value, decimals)to tidy it up:ROUND(DIVIDE({amount}, 3), 2)gives2833.33.DIVIDEreturnsnullwhen you divide by zero. - Rounding to tens, hundreds, or any step.
ROUNDalso takes a negative number of places:ROUND(1234, -2)is1200. To round to a multiple that isn't a power of ten, useMROUND(value, multiple):MROUND(1234, 10)is1230,MROUND(1260, 100)is1300, andMROUND(1234, 50)is1250, handy for prices to the nearest ₦5 or ₦50.CEILING(value, multiple)always goes up to the next multiple (CEILING(1201, 100)is1300) andFLOOR(value, multiple)always goes down (FLOOR(1299, 100)is1200); leave the multiple out and it is 1, soCEILING(2.1)is3. A number that is exactly halfway rounds away from zero (ROUND(2.5)is3,ROUND(-2.5)is-3), andROUND(1.005, 2)is1.01. A blank or non-number gives blank. ENUMandROLEreturn blank on a mismatch.ENUM("orders", "status", "Piad")andROLE("mangr")givenullinstead of passing the typo through, and forENUMthe editor also warns you with the real options. Using them for names that matter means a renamed option or role shows up straight away, instead of a formula that silently never matches.- A reference is a doorway.
{customer.name}reads thenameof the customer the order points at;{assigned_to.name}works the same through any other reference. LOOKUP(value, collection, lookupColumn, returnColumn)is for when you have a plain value and no reference to follow:LOOKUP("Ada Obi", "customers", "name", "phone")finds the customer called Ada Obi and gives back her phone number. If a field is a reference,{ref.field}is simpler.
Size limits
Formulas run on every device that opens your app, and some run on the platform's servers, so they are kept to a sensible size. You will not meet these limits writing normal formulas (the longest formula in our example apps is about 500 characters), but they are there:
| Limit | Value | What happens past it |
|---|---|---|
| Length of one formula | 10,000 characters | The editor says it is too long, and the schema is not saved. |
| Parts in one formula (names, values, brackets, commas) | 2,000 | The same: "too complex". |
Nesting, as in ADD(ADD(ADD(...))) | 64 levels | The same: "nested too deeply". |
Text built by CONCATENATE, JOIN or REPLACE, or held by a calculated field | 500,000 characters | The formula reads as empty (blank), like any formula that can't be worked out. |
Two things to know:
- A calculated field that feeds another that feeds another can only grow so far. If each field repeats the one before it (
CONCATENATE({a}, {a}), thenCONCATENATE({b}, {b})...), the text doubles at every step. It stops at the 500,000-character limit, and the field that would pass it reads as empty, along with the ones built on it. - An imported or template schema with an over-size formula is refused with a message that names where it is (for example
orders > schema > total > computed > expression), so it never reaches an app.
