Formulas Syntax & Functions
In This Article
This reference details the syntax used for Merch Jar's Formulas and automation features. Explore available properties, functions, operators, and data types to build powerful segments and workflows.
Data Types
Every value used in Merch Jar's Formulas syntax has a specific Data Type, such as Number, String, or Timestamp. Understanding these types helps ensure your comparisons and expressions are valid. This section lists the available data types and how they are used.
Type
Description
Represents numeric values. Integers (like 10) and percentages (like 25%) are treated as decimals internally. Used for properties like clicks, spend, acos, or bid.
Represents a specific point in time, stored internally as a timestamp (seconds since Unix epoch). Used for properties like last bid change or returned by now(). Compare using date operators.
Represents text values. Must be enclosed in double quotes when used as a literal value in comparisons.
Represents a predefined list of accepted string values for certain properties like state or match type. Values must be enclosed in double quotes.
Represents a span of time used for time-based properties or variables. Defined using relative (e.g., 30d), literal (e.g., 2024-01-01..2024-01-31), or offset (e.g., 7d..14d, ..14d) formats.
Represents a user-defined variable created using the let keyword. Can hold the result of expressions, calculations, case statements, or references to other variables, encompassing various data types (Number, String, List, Date, Time Period).
Built-Ins
Built-ins are the core operators, symbols, and keywords fundamental to the Formulas syntax language. Use them to perform comparisons, combine conditions with logic, do math, work with strings, and handle dates.
Built-In
Examples
Comparison Operators
=!=>>=<<= clicks(7d) = 0state != "archived"bid > 0.50spend(90d) <= 100.00 String Operators
=!=containsdoes not containstarts withends with ad group name != "Test Group"campaign name contains "Branded"campaign name starts with "High Priority" Logical Operators
andor clicks(14d) > 5 and spend(14d) > 2.00state = "enabled" or state = "paused"(orders(7d) = 0 and clicks(7d) > 10) or acos(30d) > 60% List Operators
=!=containsdoes not contain state = "effectively enabled"state != "paused"match type contains "broad"match type does not contain "loose match" Date Operators
=!=>>=<<= last bid change >= now() - interval(3d)last budget change <= now() - interval(7d) Math Operators
+-*/ bid > cpc(7d) + 0.15budget - spend(1d) < 5.00clicks(30d) * 0.01 > 1sales(14d) / orders(14d) >= 20 Properties
Properties represent the data fields and settings available in Merch Jar. Use them in filters and rules to analyze performance or check configurations. Some properties are time-based (requiring a time period like clicks(30d)), while others are static (like campaign name). Combine properties with functions and operators for advanced logic. Learn more about Time Periods →
Filter Properties
No properties match the selected filters.
| Property | Type | Description | Applies To | Account Types |
|---|---|---|---|---|
| acos | Number | Advertising Cost of Sale. Ad spend relative to ad revenue ( | CampaignsAd GroupsTargeting | KDPSellerVendor |
| ad group name | String | The current name of the Ad Group. Use with string operators like contains, starts with, etc., and quoted values. | CampaignsAd GroupsTargeting | KDPSellerVendor |
| adjusted estimated royalties | Number | Estimated KENP royalties adjusted by the KENP Impact Multiplier ( | CampaignsAd GroupsTargeting | KDP |
| adjusted orders | Number | Number of orders adjusted by the Order Impact Multiplier ( | CampaignsAd GroupsTargeting | KDP |
| adjusted page reads | Number | KENP pages read adjusted by the KENP Impact Multiplier ( | CampaignsAd GroupsTargeting | KDP |
| adjusted sales | Number | Sales revenue adjusted by the Order Impact Multiplier ( | CampaignsAd GroupsTargeting | KDP |
| aov | Number | Average Order Value. Average revenue per ad order ( | CampaignsAd GroupsTargeting | KDPSellerVendor |
| bid | Number | The current bid set for a Keyword or Target. | Targeting | KDPSellerVendor |
| blended acos | Number | Blended Advertising Cost of Sale ( | CampaignsAd GroupsTargeting | KDP |
| blended aov | Number | Blended Average Order Value ( | CampaignsAd GroupsTargeting | KDP |
| blended cac | Number | Blended Customer Acquisition Cost ( | CampaignsAd GroupsTargeting | KDP |
| blended cvr | Number | Blended Conversion Rate ( | CampaignsAd GroupsTargeting | KDP |
| blended profit | Number | Total estimated profit from ads, combining adjusted sales profit and adjusted KENP royalties. Relies on Ad Account Settings. Formula: | CampaignsAd GroupsTargeting | KDP |
| blended roas | Number | Blended Return on Ad Spend ( | CampaignsAd GroupsTargeting | KDP |
| blended rpc | Number | Blended Revenue (Profit) Per Click ( | CampaignsAd GroupsTargeting | KDP |
| budget | Number | The current daily budget set for a Campaign. | Campaigns | KDPSellerVendor |
| cac | Number | Customer Acquisition Cost. Average ad spend per ad order ( | CampaignsAd GroupsTargeting | KDPSellerVendor |
| campaign name | String | The current name of the Campaign. Use with string operators and quoted values. | CampaignsAd GroupsTargeting | KDPSellerVendor |
| clicks | Number | Total number of times ads were clicked. | CampaignsAd GroupsTargeting | KDPSellerVendor |
| cpc | Number | Cost Per Click. Average cost per ad click ( | CampaignsAd GroupsTargeting | KDPSellerVendor |
| default bid | Number | The default bid set at the Ad Group level. | Ad Groups | KDPSellerVendor |
| estimated royalties | Number | Estimated royalties from KENP pages read attributed directly to ads. | CampaignsAd GroupsTargeting | KDP |
| impressions | Number | Total number of times ads were displayed. | CampaignsAd GroupsTargeting | KDPSellerVendor |
| last bid change | Timestamp | Timestamp of the most recent bid update for a target/keyword. Compare against now() using interval(Xd). | Targeting | KDPSellerVendor |
| last budget change | Timestamp | Timestamp of the most recent Campaign budget update. Compare against now() using interval(Xd). | Campaigns | KDPSellerVendor |
| match type | List | The keyword match type or auto-targeting type. Accepted values (must be quoted): "exact", "broad", "phrase", "product exact", "similar", "close match", "loose match", "complements", "substitutes" | Targeting | KDPSellerVendor |
| orders | Number | Total number of orders directly attributed to ads. | CampaignsAd GroupsTargeting | KDPSellerVendor |
| pages read | Number | Total Kindle Edition Normalized Pages (KENP) read attributed directly to ads. | CampaignsAd GroupsTargeting | KDP |
| roas | Number | Return on Ad Spend. Ad revenue relative to ad spend ( | CampaignsAd GroupsTargeting | KDPSellerVendor |
| roi | Number | Return on Investment. Profit relative to cost ( | CampaignsAd GroupsTargeting | KDPSellerVendor |
| sales | Number | Total revenue from orders directly attributed to ads. | CampaignsAd GroupsTargeting | KDPSellerVendor |
| state | List | The current status of the entity (Campaign, Ad Group, Target, etc.). Accepted values (must be quoted): "effectively enabled", "enabled", "paused", "archived" | CampaignsAd GroupsTargeting | KDPSellerVendor |
| target acos | Number | The desired Advertising Cost of Sale (ACOS) percentage you aim for. Target ACOS is set at the Ad Account level by default and inherited by Campaigns, Ad Groups, and Targets unless a specific override value is set at a lower level. | CampaignsAd GroupsTargeting | KDPVendorSeller |
Functions
| Function | Description | Syntax | Examples |
|---|---|---|---|
let | Defines a named variable within the scope of the current Formula. Variable name must start with a $ sigil and the definition must end with a semicolon ;. Variables can store various data types (Number, String, Time Period, Properties etc.) and be referenced later. | | |
case | Evaluates conditions sequentially and returns the value associated with the first true condition. An else clause must be provided to specify a default value if no when conditions are met. Can return Properties (e.g. acos(30d)) or Number, String, or List values. Cannot return Date values. | (long form) (short form) | |
now | Returns the current timestamp (seconds since the Unix epoch). Used for time-based comparisons, often with the interval function. | | |
interval | Converts a duration (like "3d") into its equivalent value in seconds. Primarily used for date/timestamp arithmetic with the now() function. | | |
Formatting Notes
Here are key rules and conventions to remember when writing syntax for Formulas and Workflows:
- Case-Insensitivity
- Property names, function names, operators (
and,or), and list and string values (like"enabled","broad") are case-insensitive.campaign name contains "brand"is the same asCampaign Name contains "BRAND". - String Literals
- Text values used for comparison must be enclosed in double quotes ("). Example: campaign name contains "Brand".
- Numeric Values
- Standard integers and decimals are used. Percentages (
25%) are automatically treated as decimals (0.25). Currency symbols ($) are ignored; values are based on the ad account's base currency. - Time Periods
- Time-based properties require a time period specification within parentheses, like
sales(14d)orclicks(7d..14d). See the Time Periods documentation for all formats. - Comments
- Use
//to add single-line comments. Anything after//on that line is ignored. Example:clicks(7d) > 10 // Check for minimal activity - Variables (
let) - Variable names must start with a
$sigil and definitions usingletmust end with a semicolon;. Example:let $high_cpc = 1.50; - Operator Precedence
- Logical and operations are evaluated before or operations. Use parentheses () to explicitly control the order of evaluation for complex conditions. Example:
clicks > 10 and spend > 5) or acos > 50%