Skip to main content

Merchkit Formula Functions Reference

Use the Formula field type for calculations and repeatable text transformations. Enter an expression in Formula Expression when configuring a Formula attribute. Formula expressions use {{attribute_key}} to reference other attribute values, and can combine references with functions and operators (e.g., {{msrp}}+15, ROUND({{price}} * 1.1, 2)).

Extract measurements from supplier text

Suppose a product’s Supplier Notes attribute contains:
You want separate Box 1 and Box 2 measurement attributes. Before starting, make sure Supplier Notes exists on products and contains text. You need permission to manage attributes (attributes.manage). Attribute names can differ by workspace; the examples below use the key supplier_notes.
  1. Open the destination attribute’s Configure Attribute panel from Workspace → Attributes. To add one first, see Creating custom attributes.
  2. Turn Use AI off so Formula is available under Field Type. Select Formula.
  3. In Formula Expression, enter the Box 1 expression below. Use your actual source attribute key inside the double braces.
  4. Review the formula validation message, then click Save changes (or Create attribute for a new attribute).
  5. Configure a second destination attribute with the Box 2 expression. Check the calculated results on a sample product before using them in an export.
The expected results are 24 x 18 x 12 in and 30 x 20 x 15 in. Each expression returns text, including the unit. The pattern matches the exact labels and spacing in this example; adapt it to your supplier’s format.

REGEXEXTRACT syntax and limits

REGEXEXTRACT(text, pattern, groupIndex?) uses JavaScript regular-expression syntax. Write the pattern as a quoted formula string, without surrounding / characters.
  • With a capturing group in parentheses, the default result is the first group. Without a group, it is the whole match.
  • The optional third argument selects a group: 0 returns the whole match, 1 the first group, and so on. Only the first match is used.
  • Matching is case-sensitive. For example, Box 1: does not match BOX 1:.
  • No match, an invalid or empty pattern, an unavailable group, or a pattern longer than 1,000 characters returns a blank value.
  • A blank result does not distinguish missing source data from a pattern problem. Check the source text, label, spacing and group number before exporting.
For example, REGEXEXTRACT({{supplier_notes}}, "Box 1: ([^;]+)", 0) returns Box 1: 24 x 18 x 12 in. Attribute references appear as named chips in the editor but retain their {{key}} representation when copied. References must name attributes in your workspace. Formula extraction uses existing attribute text; it does not read a supplier document directly or use AI to infer missing measurements.

Text Functions

Logical Functions

Numeric Functions


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")
See the Field type guide for when to use formulas instead of AI-generated attributes.