Using math operations

How to use math operations in Plytix formulas, with real examples of when you'd use each one

Math operations let you perform calculations on your numeric attributes, from basic arithmetic to rounding and conditional totals, without changing the original stored value. This article covers all ten math operations, organized from basic arithmetic through rounding to conditional aggregation, plus common use cases combining them.

Basic arithmetic

SUM

Adds two or more numbers together.

Syntax:

SUM(value1, [value2, ...])
  • value1: the first number or range to add.
  • value2, … (optional): additional numbers or ranges to add.

Example:

SUM(1, 2, 11)

Result: 14

MULTIPLY

Returns the product of two or more numbers.

Syntax:

MULTIPLY(value1, value2, [value3, ...])
  • value1: the first multiplicand.
  • value2: the second multiplicand.
  • value3, … (optional): additional values to multiply.

Example:

MULTIPLY(1, 2, 3, 4)

Result: 24

Formula in use:

MULTIPLY($ATT.PRICE, 0.8)

This applies a 20% discount to the price stored in PRICE.

DIVIDE

Divides one number by another.

Syntax:

DIVIDE(dividend, divisor)
  • dividend: the number to be divided.
  • divisor: the number to divide by.

The divisor can’t equal 0.

Example:

DIVIDE(10, 2)

Result: 5

MINUS

Subtracts one number from another.

Syntax:

MINUS(value1, value2)
  • value1: the number to be subtracted from.
  • value2: the number to subtract from value1.

Example:

MINUS(15, 5)

Result: 10

Rounding

ROUND

Rounds a number to a specified decimal place, using normal rounding rules.

Syntax:

ROUND(value, [places])
  • value: the value to round.
  • places (optional, 0 by default): the number of decimal places to round to.

places can be negative, in which case value is rounded to that many digits to the left of the decimal point.

Example:

ROUND(15.9952, 2)

Result: 16.00

Formula in use:

ROUND($ATT.WEIGHT, 2)

This rounds the value in the WEIGHT attribute to two decimal places.

CEILING

Rounds a number up, based on a desired multiple.

Syntax:

CEILING(number_attribute, multiple)
  • number_attribute: the number attribute you want to round.
  • multiple: the multiple to round up to.

Example:

$ATT.PRICE = 14.92

CEILING($ATT.PRICE, 0.05)

Result: 14.95

FLOOR

Rounds a number down, based on a desired multiple.

Syntax:

FLOOR(number_attribute, multiple)
  • number_attribute: the number attribute you want to round.
  • multiple: the multiple to round down to.

Example:

$ATT.PRICE = 14.92

FLOOR($ATT.PRICE, 0.05)

Result: 14.90

MROUND

Rounds a number to the nearest multiple of another number. Works with both integer and decimal multiples.

p>Syntax:

MROUND(value, factor)
  • value: the number to round.
  • factor: the multiple to round to the nearest of.

Example:

MROUND(47, 10)

Result: 50

Formula in use: currency conversion with clean decimals

Converting currency at a fixed exchange rate often produces odd, awkward decimal values, for example, 100 DKK at a rate of 7.45 converts to 13.42 EUR. Wrapping the conversion in MROUND rounds the result to a cleaner, fixed decimal instead, for example, rounding to the nearest 0.25 turns that same 13.42 into 13.50:

MROUND(DIVIDE($ATT.PRICE_DKK, 7.45), 0.25)
Conditional aggregation

SUMIF

Returns the sum of a set of values, but only for the ones that meet a specified condition.

Syntax:

SUMIF(formula, value1, value2, ...)

or

SUMIF(formula, [value1, value2, ...])
  • formula: a formula that checks whether each item meets a condition.
  • value(s): a list of values, either as [value1, value2, ...] or as value1, value2, ....

Example:

$ATT.PRICE_1 = 32.44
$ATT.PRICE_2 = 29.33
$ATT.PRICE_3 = 35.22

SUMIF(GT(30, $$ITEM), $ATT.PRICE_1, $ATT.PRICE_2, $ATT.PRICE_3)

Result: 67.66

This result (67.66) equals PRICE_1 + PRICE_3 (32.44 + 35.22), the two values above 30, not PRICE_2 (29.33), the one value below 30. GT’s own confirmed example elsewhere (GT(1, 2) → False, see Operators) establishes that GT(a, b) means “a is greater than b.” Applied here, GT(30, $ITEM) should mean “30 is greater than the item,” i.e., filtering for values below 30, the opposite of what this result shows. This looks like a genuine error in the source example (likely the condition or the numbers, rather than an ambiguity in how GT’s arguments are ordered), and is worth testing directly in the formula editor before publishing, rather than assuming this example is safe to copy as-is.

COUNTIF

Counts how many times a particular value occurs within a string.

Syntax:

COUNTIF(range, test_value)
  • range: the range or string tested against the condition.
  • test_value: the pattern or value to look for.

Example:

COUNTIF("Hello World", "Hello")

Result: 1

Common Use Cases for Math Operations

Applying a bulk discount across your catalog

Use MULTIPLY to apply a percentage discount to a price attribute without editing every product by hand, and without changing the original stored price:

MULTIPLY($ATT.PRICE, 0.8)

Calculating a price-per-unit for comparison

Use DIVIDE to calculate a per-unit or per-weight price, useful for showing customers a comparison price alongside the total:

DIVIDE($ATT.PRICE, $ATT.WEIGHT)

Since the divisor can’t be 0, combine this with IFERROR (see Logical operations) if some products might have a weight of 0 or a missing value.

Using charm pricing to end every price on the same digits

Many retailers prefer prices that consistently end in a specific value, like .99 or .95, a pattern known as charm pricing. CEILING and FLOOR let you enforce this automatically across your whole catalog, rather than manually adjusting every price:

CEILING($ATT.PRICE, 0.05)

Converting currency to clean, customer-friendly decimals

As shown in MROUND’s example above, combining DIVIDE and MROUND avoids awkward converted prices like 13.42, rounding instead to a cleaner value like 13.50.

Calculating total shipping weight for a bundle

Use SUM to calculate a bundle’s total shipping weight from its individual components, keeping it accurate automatically if a component’s weight changes:

SUM($ATT.COMPONENT_1_WEIGHT, $ATT.COMPONENT_2_WEIGHT, $ATT.COMPONENT_3_WEIGHT)

Checking keyword usage for SEO

Use COUNTIF to check how many times a target keyword appears in a product description, useful for flagging descriptions that may be under- or over-optimized for a specific term:

COUNTIF($ATT.DESCRIPTION, "waterproof")

 Rounding operations (ROUND, CEILING, FLOOR, MROUND) are often combined with DIVIDE or MULTIPLY, since a raw calculated value (like a converted currency or a percentage discount) rarely lands on a clean, customer-friendly number on its own.

Frequently Asked Questions

Each function handles rounding differently based on precision or multiples:

  • ROUND rounds a number to a specified number of decimal places using standard rounding rules (0.5 and above rounds up).
  • CEILING always rounds a number up to the nearest specified multiple.
  • FLOOR always rounds a number down to the nearest specified multiple.
  • MROUND rounds a number up or down to the closest specified multiple.

No. Division by zero is not supported and will result in an error. Wrap DIVIDE in an IFERROR function (or check the divisor with IF) to handle zero or missing values safely.

  • SUM calculates the total of all provided values.
  • SUMIF calculates the total of only the values that meet your specified criteria.