Features
Merch Jar Formulas use a specific syntax to define logic for filtering data and creating custom calculations. Understanding these core components and terms is key to writing effective formulas.
Formulas combine several types of elements:
Represent data fields (like clicks
, spend
) or settings (like campaign name
, bid
) available within Merch Jar. They are the primary data points you'll filter or calculate with. Properties are either time-based or static.
sales
, acos
) measure performance over time and always require a Time Period specification enclosed in parentheses like (30d)
.campaign name
, bid
) reflect current settings and do not use a Time Period.Symbols or keywords used for comparison (>
, =
, contains
), logic (and
, or
), or math (+
, *
). They define the relationship between properties and values.
The specific numbers (10
, 25%
), text ("Brand Campaign"
), or list items ("enabled"
) you compare properties against. String values must be quoted. Timestamp values typically result from date properties or the now()
function.
Every value has an underlying Data Type (Number, String, Timestamp, etc.). Comparisons and operations generally require compatible types.
Perform specific calculations or return dynamic values, like getting the current time (now()
), implementing conditional logic (case()
), or converting durations (interval()
).
Used with the let
keyword to define intermediate calculations or values within your formula, making complex logic easier to read and manage. These definitions also create Custom Properties. Variable names must start with a $
sigil and definitions must end with a semicolon ;
.
Learn about Creating Custom Properties
The named outputs created by let variable definitions. These appear as distinct columns in your resulting Segment table, showing the calculated value for each item that passes the filter. Underscores in the variable name (let $target_cpc = ...
) are replaced with spaces in the column header (Target CPC
).
Required for time-based properties to specify the date range (e.g., 30d
, 7d..14d
, YYYY-MM-DD..YYYY-MM-DD
).
Learn about Using Time Periods
Parentheses control the order in which complex logical (and
/or
) or mathematical expressions are evaluated.
Learn about Boolean Logic & Grouping
Add explanatory notes within your formula that are ignored by the system.
A Formula consists of two main parts:
let
function, each ending in a semicolon (;
), creating Custom Properties.clicks(lifetime) >= 0
is currently needed.// Part 1: Variable Definitions (creating Custom Properties)
let $avg_sales = sales(90d) / 3;
let $threshold = avg_sales * 0.9;
// Part 2: Formula Expressions (defining the Segment)
sales(30d) < $threshold
Now that you understand the basic structure, explore the specific components:
© Merch Jar LLC