Articles on: Building Calculators

Formula Reference: Every Operator, Function and Variable CPC Supports

Everything the formula field accepts, and the handful of things it does not. If a formula will not save, the answer is almost always on this page.


Supported


Operators+ - * / and parentheses.


Comparisons> < >= <= == !=. You can write = for equals and <> for not-equals if that is the spreadsheet habit; both are understood.


Functionsceil(), ceiling(), floor(), sqrt(), if(), max(), min(), and(), or().


Conditionsif(condition, value when true, value when false), written the way you would in Excel. The ternary form condition ? a : b works too, and && joins two conditions. Functions can be nested inside one another.


Variables — your element labels, plus shopify_product_price.


Not supported


pow(), round() and abs() — these three are genuinely absent. ^ for exponentiation is not accepted either.


No Math. prefix — write ceil(Width), never Math.ceil(Width).


Chaining calculations — one Calculation element cannot reference another. Write the full logic out in each formula.


Text — a formula returns a number, always. It cannot return a message, and it cannot read one from a Text Input.


Rounding, when there is no round()


Two settings do the job instead:


  • Formula Output Decimals, in the calculator's settings, controls how many decimal places the price shows. Set it to 2 for currency.
  • ceil() and floor() round a value up or down to a whole number inside the formula — useful for whole units of material rather than for money.


Minimum and maximum prices


You now have two ways to floor a price, and they are not the same thing.


max(your formula, 25) inside the formula guarantees the result is never below 25.


Minimum Formula Value, in the calculator's settings, does the same to the finished result and also fixes the "calculator shows 0.00 before anything is entered" problem, which matters for Google Merchant Center.


One trap worth knowing: Minimum Formula Value floors the whole result, so an add-on fee can be swallowed on small orders until the total climbs above the floor. If that bites, set minimums on the input fields instead, so the formula reaches the floor naturally.


Conditional pricing


A price that changes past a threshold is now a single line:


Width * Height / 144 * 4.50 + if(Width > 45, 85, 0)


That charges $4.50 per square foot and adds an $85 oversize fee once the width goes over 45 inches. Conditions can be combined:


if(Width > 45 && Height > 45, 120, 0)


and() and or() belong in the condition, not in the arithmetic. They return true or false rather than a number, so they only work as the first part of an if(). if(and(Width > 20, Height > 10), 200, 100) is fine; sqrt(10) + and(Width > 1, Height > 1) is not.


Write decimals with a dot inside if(). A comma is how if() separates its three parts, so if(Width > 5, 1,5, 0) is read as four parts and rejected when you save. Write 1.5.


A Data Lookup is still the better tool for several bands. Three or four price brackets as nested if() calls become hard to read and harder to change; a lookup table in range mode holds them as rows you can edit. Use if() for one or two conditions, a lookup for a table.


Referencing your elements


Element labels must match their element's spelling, spaces and punctuation. Capitalisation is the one thing that does not have to match — width, Width and WIDTH all resolve to a field labelled Width, and the formula is saved back using the field's own capitalisation. A Number Input in range mode gives you two forms: LabelName returns the range's value, and LabelName[actualvalue] returns the number the customer actually typed.


Copy-pasting labels from elsewhere can carry invisible characters the parser rejects. If a formula looks correct and still will not save, retype the element names by hand.


Metafields


Two rules, and both break formulas silently when missed. A metafield must be registered in the calculator's Product Metafields setting with its namespace and key, and it must hold a numeric value on the product. An unregistered token does not error — it quietly resolves to a fallback, and your price comes out wrong rather than broken.


Metafields are read once when the page loads, not live.


When a formula refuses to save


Work down this list:


  1. A function that is not on the supported list — most often round(), abs() or pow().
  2. A Math. prefix.
  3. An element label that does not match its element exactly.
  4. Invisible characters from a copy-paste. Retype it.
  5. A reference to another Calculation element.


The preview evaluator is more forgiving than the save gate, so a formula can look fine in preview and still be rejected. The save gate is the one that counts.


Still stuck?


The formula field suggests functions and variables as you type, and offers a route into Calcy, the AI builder, when you would rather describe the pricing in plain English than write it. Support can also look at your calculator directly — send your store URL and the product page.

Updated on: 20/08/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!