Skip to main content

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})
REPLACE(text, search, replacement)Replace first occurrence of textREPLACE({name}, "-", " ")
SUBSTITUTE(text, oldText, newText)Replace all occurrences of textSUBSTITUTE({description}, "old", "new")
TEXT(value)Format a value as textTEXT({price})
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, "-")
CONTAINS(text, search)Check if text contains a substring (returns boolean)CONTAINS({description}, "premium")

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")
IFS(cond1, result1, cond2, result2, ...)Return value based on multiple conditionsIFS({score} > 90, "A", {score} > 80, "B", true, "C")

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})

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.