Skip to main content
Formula fields in Softr allow you to perform calculations, manipulate text, work with dates, and create conditional logic to enhance your Database’s functionality. Each function is listed with its syntax and an example to demonstrate its use.

Introduction to Formula Fields

Formula fields in Softr are a powerful field type that enable you to compute values based on other fields in your Database. You can add a formula field to a table like any other field type, then write a formula to generate outputs such as numbers, dates, or text strings. These fields automatically update when referenced data changes, making them ideal for dynamic calculations and data manipulation.

To create a formula field:

  1. Add a new field to your table in Softr.
  2. Select “Formula” as the field type.
  3. Enter the formula in the formula editor, referencing other fields and using the functions below.
  4. Configure the output format (e.g., number, date, or string) under the Formatting tab.

Formula Syntax

  • When referencing other fields inside a formula, always put them in curly brackets, like so: {Contact Name} or {Status}
  • When you use a function, the function only applies to what is inside the parentheses (). If you need to place functions inside other functions, you can use multiple parentheses, like so:
SUM({Price}, ({Price}*{Tax Rate}))
  • Static, text based values always need to be inside quotation marks like so:
IF({Rating}<=3, "At Risk", "Nominal")
  • Arrays (lists of items) are always displayed inside square brackets []

Formula Functions and Operators

Text Functions

CONCATENATE(text1, text2, ...) Combines multiple text strings into a single string. Example:
CONCATENATE({First Name}, " ", {Last Name})
If First Name is “Jane” and Last Name is “Doe”, the result is “Jane Doe”. Alternative, you can also use the ampersand symbol & to combine text together, like so:
{First Name} & {Last Name}

LEFT(string, howMany) Extracts a specified number of characters from the start of a string. Example:
LEFT({Project Name}, 3)
If Project Name is “Website Redesign”, the result is “Web”.
RIGHT(string, howMany) Extracts a specified number of characters from the end of a string. Example:
RIGHT({Product Code}, 4)
If Product Code is “ITEM-1234”, the result is “1234”.
LEN(string) Returns the length of a string in characters, including symbols and spaces. Example:
LEN({Description})
If Description is “Softr is awesome”, the result is 16.
FIND(search_text, within_text, [start_position]) Locates the position of a substring within a string. Returns 0 if not found. Example:
FIND("Softr", {App Name})
If App Name is “Build with Softr”, the result is 12.
SEARCH(search_text, within_text, [start_position]) Similar to FIND, but case-insensitive. Returns 0 if not found. Example:
SEARCH("softr", {App Name})
If App Name is “Build with SOFTR”, the result is 12.
SUBSTITUTE(text, old_text, new_text, [instance_num]) Replaces occurrences of a specified substring with new text. Example:
SUBSTITUTE({Title}, "Old", "New")
If Title is “Old Project”, the result is “New Project”.
TRIM(text) Removes leading and trailing spaces from a string. Example:
TRIM({User Input})
If User Input is ” Hello ”, the result is “Hello”.
LOWER(text) Converts a string to lowercase. Example:
LOWER({Email})
If Email is “User@Example.com”, the result is “user@example.com”.
UPPER(text) Converts a string to uppercase. Example:
UPPER({Status})
If Status is originally “pending”, the result is “PENDING”.
CAPITALIZE(string) Converts the first character of a string to uppercase and the remaining characters to lowercase. Example:
CAPITALIZE({Status})
If Status is “in progress”, the result is “In progress”.
PROPER(string) Capitalizes the first letter of each word in a text string and converts all other letters to lowercase. Example:
PROPER({Full Name})
If Full Name is “jane doe”, the result is “Jane Doe”.
DOMAIN(url) Extracts the domain name from a URL. Example:
DOMAIN({Website})
If Website is “https://www.example.com/page”, the result is “example.com”.
MID(string, start_position, length) Extracts a substring from a string, starting at the specified position and continuing for the specified length. Example:
MID({Product Code}, 6, 4)
If Product Code is “ITEM-1234-XYZ”, the result is “1234”.
REPT(text, number_times) Repeats a text string a specified number of times. Example:
REPT("*", 5)
The result is ”*****”.
T(value) Returns the text value of the input, or an empty string if the input is not text. Example:
T({Price})
If Price is 100, the result is “100”. If Price is a date, the result is "".

Logical Functions

=, !=, >, <, >=, <= Comparison operators that return TRUE or FALSE. Example:
{Total} >= 1000
If Total is 1500, the result is TRUE.
IF(logical_test, value_if_true, value_if_false) Returns one value if a condition is true, another if false. Example:
IF({Total} > 1000, "Large Order", "Small Order")
If Total is 1500, the result is “Large Order”.
AND(logical1, logical2, ...) Returns TRUE if all arguments are true, FALSE otherwise. Example:
AND({In Stock} = 1, {Price} > 50)
If In Stock is checked and Price is 75, the result is TRUE.
OR(logical1, logical2, ...) Returns TRUE if any argument is true, FALSE otherwise. Example:
OR({Status} = "Open", {Status} = "In Progress")
If Status is “Open”, the result is TRUE.
NOT(logical) Reverses the logical value of its argument. Example:
NOT({Completed})
If Completed is checked (TRUE), the result is FALSE.
XOR(logical1, logical2, ...) Returns TRUE if an odd number of arguments are true, FALSE otherwise. Example:
XOR({Option A}, {Option B})
If Option A is TRUE and Option B is FALSE, the result is TRUE. If both are TRUE, the result is FALSE.
SWITCH(expression, value1, result1, [value2, result2, ...], default) Evaluates an expression and returns a result based on matching values. Example:
SWITCH({Priority}, 1, "High", 2, "Medium", 3, "Low", "Unknown")
If Priority is 2, the result is “Medium”.

Numeric Functions

+, -, *, / Performs addition, subtraction, multiplication, or division on numbers. Example:
{Price} * 1.1
If Price is 100, the result is 110 (adds 10%).
^ Raises a number to a power (alternative to POWER). Example:
{Base Value}^2
If Base Value is 5, the result is 25 (5²).
ROUND(number, num_digits) Rounds a number to a specified number of decimal places. Example:
ROUND({Total Cost}, 2)
If Total Cost is 123.456, the result is 123.46.
CEILING(number, [significance]) Rounds a number up to the nearest integer, or to the nearest multiple of significance if specified. Example:
CEILING({Quantity})
If Quantity is 5.2, the result is 6.
CEILING({Price}, 10)
If Price is 23, the result is 30.
FLOOR(number, [significance]) Rounds a number down to the nearest integer, or to the nearest multiple of significance if specified. Example:
FLOOR({Score})
If Score is 7.8, the result is 7.
FLOOR({Price}, 10)
If Price is 27, the result is 20.
ABS(number) Returns the absolute value of a number. Example:
ABS({Balance})
If Balance is -50, the result is 50.
SUM(number1, number2, ...) Adds a list of numbers. Example:
SUM({Price1}, {Price2})
If Price1 is 100 and Price2 is 200, the result is 300.
AVERAGE(number1, number2, ...) Calculates the average of a list of numbers. Example:
AVERAGE({Score1}, {Score2}, {Score3})
If Score1 is 80, Score2 is 90, and Score3 is 100, the result is 90.
MIN(number1, number2, ...) Returns the smallest number in a list. Example:
MIN({Bid1}, {Bid2})
If Bid1 is 500 and Bid2 is 450, the result is 450.
MAX(number1, number2, ...) Returns the largest number in a list. Example:
MAX({Revenue Q1}, {Revenue Q2})
If Revenue Q1 is 1000 and Revenue Q2 is 1200, the result is 1200.
COUNT(array) Counts the number of non-null items in an array. Example:
COUNT({Tasks Lookup})
If Tasks Lookup contains [“Task1”, "", “Task2”, “Task3”], the result is 3.
MOD(number, divisor) Returns the remainder after dividing the number by the divisor. Example:
MOD({Total Items}, 3)
If Total Items is 10, the result is 1 (10 ÷ 3 leaves a remainder of 1).
POWER(base, exponent) Raises a number to the specified exponent. Example:
POWER({Base Value}, 2)
If Base Value is 5, the result is 25 (5²).
SQRT(number) Returns the square root of a non-negative number. Example:
SQRT({Area})
If Area is 16, the result is 4.
RANDBETWEEN(low, high) Returns a random integer between the specified low and high values (inclusive). Example:
RANDBETWEEN(1, 100)
The result is a random number between 1 and 100, such as 42.

Date and Time Functions

For a full list of Date and Time formatting options, please see this article. DATETIME_FORMAT(date, format) Formats a date/time value as a text string. Example:
DATETIME_FORMAT({Due Date}, "MM/DD/YYYY")
If Due Date is 2025-06-15, the result is “06/15/2025”.
DATETIME_PARSE(string, format) Converts a text string to a date/time value. Example:
DATETIME_PARSE({Date Text}, "MM/DD/YYYY")
If Date Text is “12/31/2025”, the result is a date value of 2025-12-31.
SET_TIMEZONE(date, timezone) Sets a specific timezone for a date field. Example:
SET_TIMEZONE({Event Date}, "America/New_York")
If Event Date is 2025-05-29 14:00 UTC, the result is 2025-05-29 10:00 EDT.
NOW() Returns the current date and time. Example:
NOW()
If the current time is May 29, 2025, 16:42 EDT, the result is 2025-05-29 16:42.
TODAY() Returns the current date without time. Example:
TODAY()
If today is May 29, 2025, the result is 2025-05-29.
DATEADD(date, number, unit) Adds a specified number of units (e.g., days, months) to a date. Example:
DATEADD({Start Date}, 7, "days")
If Start Date is 2025-06-01, the result is 2025-06-08.
DATETIME_DIFF(date1, date2, unit) Calculates the difference between two dates in the specified unit (e.g., days, hours). Example:
DATETIME_DIFF({Due Date}, {Start Date}, "days")
If Due Date is 2025-06-10 and Start Date is 2025-06-01, the result is 9.
CREATED_TIME() Returns the date and time when the record was created. Example:
DATETIME_FORMAT(CREATED_TIME(), "MM/DD/YYYY")
If the record was created on May 29, 2025, the result is “05/29/2025”.
IS_SAME(date1, date2, [unit]) Returns 1 if two dates are identical, or 0 otherwise. Optionally compares at a specified unit (e.g., “day”, “month”). Example:
IS_SAME({Start Date}, {End Date}, "day")
If Start Date and End Date are both 2025-06-01, the result is 1.
IS_AFTER(date1, date2) Returns 1 if date1 is after date2, or 0 otherwise. Example:
IS_AFTER({Due Date}, TODAY())
If Due Date is 2025-06-10 and today is May 29, 2025, the result is 1.
IS_BEFORE(date1, date2) Returns 1 if date1 is before date2, or 0 otherwise. Example:
IS_BEFORE({Start Date}, TODAY())
If Start Date is 2025-05-01 and today is May 29, 2025, the result is 1.
LAST_MODIFIED_TIME() Returns the most recent modification time for the record. Example:
DATETIME_FORMAT(LAST_MODIFIED_TIME(), "MM/DD/YYYY")
If the record was last modified on May 28, 2025, the result is “05/28/2025”.
WORKDAY(start_date, num_days) Returns a date that is a specified number of working days from the start date, excluding weekends. Example:
WORKDAY({Start Date}, 5)
If Start Date is 2025-06-02 (Monday), the result is 2025-06-09 (Monday, 5 workdays later).
WORKDAY_DIFF(start_date, end_date) Returns the number of working days between two dates, excluding weekends. Example:
WORKDAY_DIFF({Start Date}, {End Date})
If Start Date is 2025-06-02 and End Date is 2025-06-09, the result is 5 workdays.
WEEKDAY(date, [startDayOfWeek]) Returns the day of the week as a number. By default, the week starts on Sunday (0 = Sunday, 1 = Monday, …, 6 = Saturday). Pass “monday” as the second argument to start the week on Monday instead. Example:
WEEKDAY({Due Date})
If Due Date is 2025-06-02 (a Monday), the result is 1.
WEEKDAY({Due Date}, "monday")
If Due Date is 2025-06-02 (a Monday), the result is 0.
WEEKNUM(date, [startDayOfWeek]) Returns the week number of the year for a given date. By default, the week starts on Sunday. Pass “monday” as the second argument to start the week on Monday instead. Example:
WEEKNUM({Due Date})
If Due Date is 2025-06-02, the result is 23.
DATESTR(date) Converts a date to a string in “YYYY-MM-DD” format. Example:
DATESTR({Start Date})
If Start Date is June 1, 2025, the result is “2025-06-01”.
DATE(value) Converts a value to a date type. Example:
DATE("2025-06-15")
The result is a date value of 2025-06-15.
DATETIME(value) Converts a value to a datetime type. Example:
DATETIME("2025-06-15 14:30:00")
The result is a datetime value of 2025-06-15 14:30:00.
EDATE(date, [months]) Returns the date that is the specified number of months before or after the start date, keeping the same day. If the day doesn’t exist in the target month, it rolls to the last day of the target month. If months is omitted, defaults to 0. Example:
EDATE({Start Date}, 3)
If Start Date is 2025-01-31, the result is 2025-04-30 (April has no 31st, so it rolls to the last day).
EOMONTH(date, [months]) Returns the last day of the month that is the specified number of months before or after the start date. If months is omitted, defaults to 0 (returns last day of the current month). Example:
EOMONTH({Start Date}, 1)
If Start Date is 2025-06-15, the result is 2025-07-31 (last day of the following month).
DAY(date) Returns the day of the month from a date. Example:
DAY({Due Date})
If Due Date is 2025-06-15, the result is 15.
MONTH(date) Returns the month from a date (1–12). Example:
MONTH({Due Date})
If Due Date is 2025-06-15, the result is 6.
YEAR(date) Returns the year from a date. Example:
YEAR({Due Date})
If Due Date is 2025-06-15, the result is 2025.
HOUR(date) Returns the hour from a datetime value (0–23). Example:
HOUR({Created Time})
If Created Time is 2025-06-15 14:30:00, the result is 14.
MINUTE(date) Returns the minute from a datetime value (0–59). Example:
MINUTE({Created Time})
If Created Time is 2025-06-15 14:30:00, the result is 30.
SECOND(date) Returns the second from a datetime value (0–59). Example:
SECOND({Created Time})
If Created Time is 2025-06-15 14:30:45, the result is 45.
DAYS_IN_MONTH([date]) Returns the number of days in the month of the given date. If no date is provided, uses the current date. Example:
DAYS_IN_MONTH({Due Date})
If Due Date is 2025-02-15, the result is 28.

Array Functions

ARRAYCOMPACT(values) Removes empty or null values from a list and returns the result as a comma-separated string. Example:
ARRAYCOMPACT({Tasks Lookup})
If Tasks Lookup contains [“Task1”, "", “Task2”], the result is “Task1, Task2”.
ARRAYJOIN(values, [delimiter]) Joins array elements into a single string, separated by an optional delimiter. Example:
ARRAYJOIN({Tags Lookup}, ", ")
If Tags Lookup contains [“Red”, “Blue”], the result is “Red, Blue”.
ARRAYUNIQUE(values) Removes duplicate values from a list and returns the result as a comma-separated string. Example:
ARRAYUNIQUE({Categories Lookup})
If Categories Lookup contains [“A”, “B”, “A”], the result is “A, B”.
ARRAYSLICE(array, start, [end]) Extracts a portion of an array from the start index to the optional end index (exclusive). Indexes are 1-based. Example:
ARRAYSLICE({Tags Lookup}, 2, 4)
If Tags Lookup contains [“A”, “B”, “C”, “D”], the result is “B, C”.

Regular Expression Functions

REGEX_MATCH(string, pattern) Returns TRUE if the string matches the regular expression pattern. Example:
REGEX_MATCH({Email}, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")
If Email is “user@example.com”, the result is TRUE.
REGEX_EXTRACT(string, pattern) Extracts the first substring that matches the regular expression pattern. Example:
REGEX_EXTRACT({Code}, "[0-9]+")
If Code is “ITEM-1234-XYZ”, the result is “1234”.
REGEX_REPLACE(string, pattern, replacement) Replaces the first match of the regular expression pattern with the replacement string. Example:
REGEX_REPLACE({Phone}, "\D", "")
If Phone is “(123) 456-7890”, the result is “1234567890”.

Other Functions

RECORD_ID() Returns the unique identifier for a record. Example:
RECORD_ID()
If the record’s ID is “rec1234567890”, the result is “rec1234567890”. Alternatively, if you just need the Record ID, you can also use a Record ID field type.
ISERROR(value) Checks if a value or expression results in an error, returning TRUE or FALSE. Example:
ISERROR({Price} / 0)
If Price divided by 0 causes an error, the result is TRUE.
BLANK() Returns an empty string. Example:
IF({Name} = "", BLANK(), {Name})
If Name is empty, the result is an empty string; otherwise, it returns the value of Name.
ERROR() Returns an error value. Example:
IF({Quantity} < 0, ERROR(), {Quantity} * {Price})
If Quantity is -1, the result is an error.
IFERROR(expression, fallback) Returns the value of the expression if it is not an error; otherwise, returns the fallback value. Example:
IFERROR({Total} / {Count}, 0)
If Count is 0 and the division causes an error, the result is 0.
TRUE() Returns the number 1 (true). Example:
IF(TRUE(), "Always", "Never")
The result is “Always”.
FALSE() Returns the number 0 (false). Example:
IF(FALSE(), "Always", "Never")
The result is “Never”.

Tips for Writing Formulas

  • Plan Ahead: Before writing a formula, outline your goal in plain language (e.g., “Calculate the days remaining until a deadline”).
  • Check Syntax: Softr’s formula editor highlights errors. Ensure field names are correct and enclosed in curly braces {}.
  • Use Nesting: Combine functions for complex logic, such as nested IF statements:
IF({Score} > 90, "A", IF({Score} > 80, "B", "C"))
  • Format Outputs: Use the Formatting tab to set the desired output format (e.g., decimal places for numbers, date styles for dates).
  • Test Thoroughly: Preview your formula results in Softr to confirm they behave as expected.

Common Use Cases

  • Dynamic Text: Combine names or create custom labels:Result: “New York - USA”
CONCATENATE({City}, " - ", {Country})
  • Conditional Logic: Categorize records based on criteria:Result: “High” or “Low”
IF({Revenue} > 10000, "High", "Low")
  • Date Calculations: Track project timelines:Result: Number of days until the due date
DATETIME_DIFF({Due Date}, TODAY(), "days")
  • Numeric Calculations: Compute totals or percentages:Result: 10% of Price, rounded to two decimals
ROUND({Price} * 0.1, 2)

Limitations

  • Formula fields are read-only and cannot be manually edited.
  • Complex formulas may impact performance in large Databases.
  • Some functions (e.g., FIND vs. SEARCH) are case-sensitive; choose the appropriate function for your needs.
  • Ensure referenced fields exist and contain valid data to avoid errors.

Additional Resources

  • Softr Academy: Visit the Softr Academy to take full courses on building Softr apps.
  • Community Forums: Join the Softr community to ask questions and share tips.
  • Support: Contact Softr support at support@softr.io if you get stuck with your Database setup.