Merchkit Formula Functions Reference
This reference documents all available functions for the Formula field type in Merchkit. Use these via the "Insert Function" button when configuring a Formula attribute.
Formula expressions use {{attribute_name}} to reference other attribute values, and can combine references with functions and operators (e.g., {{msrp}}+15, ROUND({{price}} * 1.1, 2)).
Text Functions
| Function | Description | Example |
|---|---|---|
CONCATENATE(text1, text2, ...) | Join multiple text values into one string | CONCATENATE({brand}, " - ", {name}) |
UPPER(text) | Convert text to uppercase | UPPER({brand}) |
LOWER(text) | Convert text to lowercase | LOWER({brand}) |
TRIM(text) | Remove leading and trailing whitespace | TRIM({description}) |
LEFT(text, count) | Extract characters from the start of text | LEFT({sku}, 3) |
RIGHT(text, count) | Extract characters from the end of text | RIGHT({sku}, 4) |
MID(text, start, count) | Extract characters from the middle of text (1-based) | MID({sku}, 4, 3) |
LEN(text) | Get the length of text | LEN({description}) |
SUBSTITUTE(text, oldText, newText) | Replace all occurrences of text | SUBSTITUTE({description}, "old", "new") |
FIND(findText, withinText) | Find the 1-based position of text within another string (0 if not found, case-sensitive) | FIND("-", {sku}) |
LPAD(text, length, padChar?) | Pad text on the left to reach target length | LPAD({quantity}, 4, "0") |
RPAD(text, length, padChar?) | Pad text on the right to reach target length | RPAD({code}, 10, "-") |
REPT(text, count) | Repeat text a specified number of times | REPT("0", 3) |
CONTAINS(text, search) | Check if text contains a substring, case-insensitive (returns boolean) | CONTAINS({description}, "premium") |
Logical Functions
| Function | Description | Example |
|---|---|---|
IF(condition, ifTrue, ifFalse) | Return different values based on a condition | IF({price} > 100, "Premium", "Standard") |
ISBLANK(value) | Check if a value is empty or null | ISBLANK({sale_price}) |
COALESCE(value1, value2, ...) | Return the first non-blank value | COALESCE({sale_price}, {price}, 0) |
AND(condition1, condition2, ...) | Return true if all conditions are true | AND({active}, {in_stock}) |
OR(condition1, condition2, ...) | Return true if any condition is true | OR({featured}, {on_sale}) |
NOT(value) | Return the opposite boolean value | NOT({discontinued}) |
SWITCH(expr, case1, result1, ...) | Return value based on matching expression | SWITCH({status}, "A", "Active", "I", "Inactive", "Unknown") |
BLANK() | Return an empty value (null) | IF({discontinued}, BLANK(), {price}) |
Numeric Functions
| Function | Description | Example |
|---|---|---|
ROUND(number, decimals?) | Round a number to specified decimal places | ROUND({price}, 2) |
FLOOR(number) | Round down to nearest integer | FLOOR({quantity}) |
CEILING(number) | Round up to nearest integer | CEILING({quantity}) |
ABS(number) | Return the absolute value | ABS({difference}) |
MIN(number1, number2, ...) | Return the minimum value | MIN({price}, {sale_price}) |
MAX(number1, number2, ...) | Return the maximum value | MAX({price}, {min_price}) |
SUM(number1, number2, ...) | Add multiple numbers together | SUM({price}, {tax}, {shipping}) |
AVERAGE(number1, number2, ...) | Calculate the average of numbers | AVERAGE({rating1}, {rating2}, {rating3}) |
MOD(dividend, divisor) | Return the remainder of division | MOD({quantity}, 12) |
POWER(base, exponent) | Raise a number to a power | POWER({side}, 2) |
SQRT(number) | Return the square root of a number | SQRT({area}) |
Date Functions
All date functions work with Unix timestamps (seconds since 1970-01-01). Use arithmetic on timestamps to compute durations, e.g. NOW() - DATEVALUE({launch_date}) gives an age in seconds.
| Function | Description | Example |
|---|---|---|
DATEVALUE(dateString) | Convert a date string (e.g. "2026-03-09") to a Unix timestamp | DATEVALUE({launch_date}) |
NOW() | Current Unix timestamp | NOW() |
TODAY() | Unix timestamp for the start of today (midnight UTC) | TODAY() |
Common Patterns
Markup calculation: {{msrp}} + 15 or ROUND({{cost}} * 1.4, 2)
Conditional pricing: IF({{sale_price}} > 0, {{sale_price}}, {{price}})
SKU generation: CONCATENATE(LEFT({{brand}}, 3), "-", {{product_id}})
Null-safe display: COALESCE({{sale_price}}, {{price}}, "Contact for price")
Category mapping: SWITCH({{category}}, "Sofas", "Living Room", "Tables", "Dining", "Other")
Validation check: IF(AND(NOT(ISBLANK({{width}})), NOT(ISBLANK({{height}})), NOT(ISBLANK({{depth}}))), "Complete", "Missing dimensions")
This reference is part of the Merchkit Knowledge Base. See article 3.6a (Field Type Guide) for when to use Formulas vs. AI-generated attributes.