Reference

Formula Functions Reference

Complete reference of all available functions for the Formula field type in Merchkit — text, logical, and numeric functions with examples.

On this page

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

FunctionDescriptionExample
CONCATENATE(text1, text2, ...)Join multiple text values into one stringCONCATENATE({brand}, " - ", {name})
UPPER(text)Convert text to uppercaseUPPER({brand})
LOWER(text)Convert text to lowercaseLOWER({brand})
TRIM(text)Remove leading and trailing whitespaceTRIM({description})
LEFT(text, count)Extract characters from the start of textLEFT({sku}, 3)
RIGHT(text, count)Extract characters from the end of textRIGHT({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 textLEN({description})
SUBSTITUTE(text, oldText, newText)Replace all occurrences of textSUBSTITUTE({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 lengthLPAD({quantity}, 4, "0")
RPAD(text, length, padChar?)Pad text on the right to reach target lengthRPAD({code}, 10, "-")
REPT(text, count)Repeat text a specified number of timesREPT("0", 3)
CONTAINS(text, search)Check if text contains a substring, case-insensitive (returns boolean)CONTAINS({description}, "premium")
REMOVELIST(text, itemsToRemove, delimiter?)Remove whole items from a delimited list, in any order (case-insensitive). Surviving items keep their original text and order. Delimiter defaults to ", "REMOVELIST({tags}, {tags_remove}, ", ")
ADDLIST(text, itemsToAdd, delimiter?)Add whole items to a delimited list, skipping any already present (case-insensitive). Existing items are kept; new items are appended. Delimiter defaults to ", "ADDLIST({tags}, "Sale, Clearance", ", ")
REGEXEXTRACT(text, pattern, groupIndex?)Extract text matching a regular expression. Returns the first capturing group (or the whole match if the pattern has none); blank when nothing matches. Optional groupIndex selects a specific group (0 = whole match)REGEXEXTRACT({spec}, "Color:\s*(.*)")

Logical Functions

FunctionDescriptionExample
IF(condition, ifTrue, ifFalse)Return different values based on a conditionIF({price} > 100, "Premium", "Standard")
ISBLANK(value)Check if a value is empty or nullISBLANK({sale_price})
COALESCE(value1, value2, ...)Return the first non-blank valueCOALESCE({sale_price}, {price}, 0)
AND(condition1, condition2, ...)Return true if all conditions are trueAND({active}, {in_stock})
OR(condition1, condition2, ...)Return true if any condition is trueOR({featured}, {on_sale})
NOT(value)Return the opposite boolean valueNOT({discontinued})
SWITCH(expr, case1, result1, ...)Return value based on matching expressionSWITCH({status}, "A", "Active", "I", "Inactive", "Unknown")
BLANK()Return an empty value (null)IF({discontinued}, BLANK(), {price})

Numeric Functions

FunctionDescriptionExample
ROUND(number, decimals?)Round a number to specified decimal placesROUND({price}, 2)
FLOOR(number)Round down to nearest integerFLOOR({quantity})
CEILING(number)Round up to nearest integerCEILING({quantity})
ABS(number)Return the absolute valueABS({difference})
MIN(number1, number2, ...)Return the minimum valueMIN({price}, {sale_price})
MAX(number1, number2, ...)Return the maximum valueMAX({price}, {min_price})
SUM(number1, number2, ...)Add multiple numbers togetherSUM({price}, {tax}, {shipping})
AVERAGE(number1, number2, ...)Calculate the average of numbersAVERAGE({rating1}, {rating2}, {rating3})
MOD(dividend, divisor)Return the remainder of divisionMOD({quantity}, 12)
POWER(base, exponent)Raise a number to a powerPOWER({side}, 2)
SQRT(number)Return the square root of a numberSQRT({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.

FunctionDescriptionExample
DATEVALUE(dateString)Convert a date string (e.g. "2026-03-09") to a Unix timestampDATEVALUE({launch_date})
NOW()Current Unix timestampNOW()
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")

Edit a tag list: REMOVELIST({{tags}}, {{tags_to_remove}}, ", ") strips unwanted tags in any order; ADDLIST({{tags}}, "Sale, Clearance", ", ") appends new tags without creating duplicates. Both split on the comma, so multi-word tags like Office Lighting stay intact.

Extract a value from text: REGEXEXTRACT({{spec}}, "Color:\s*(.*)") pulls the color out of a spec line like Color: Tropic Paradise. Patterns use standard regular-expression syntax with single-backslash metacharacters (\s, \d, \.) — no double-escaping needed. The capturing group (...) is what gets returned; add a groupIndex to pick a different group.

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.