跳转到内容
Agentic Workflowdocs
v0.8.2免费安装

节点 / builtin / datatransformation

Math

Calculate with numbers and format them for people

数据 扩展程序网页应用

此内容尚不支持你的语言。

Calculate with numbers and format them for people.

Math does one calculation and puts the answer in a field (result by default). The operations are:

  • Two numbers: Add, Subtract, Multiply, Divide, Remainder, Power, Percentage of, Percentage change.
  • One number: Round, Round down, Round up, Drop decimals, Absolute value, Negate, Square root.
  • A list: Minimum, Maximum, Sum, Average.
  • Other: Random number, and Format, which writes a number with separators, a currency or a percent sign.

Math is strict about input. Numbers and number-like text such as "42" are accepted. Empty text, a missing field, null, a list or true/false stop the run with a message, so a missing price never silently counts as zero. Dividing by zero also stops the run instead of returning infinity.

Round avoids the usual decimal trap: rounding 1.005 to 2 decimals gives 1.01.

  • Turn a scraped price like "19.99" into a number and do sums with it.
  • Total or average a column of values, for example after Aggregate.
  • Work out a discount or a price change as a percentage.
  • Present a number for people: 1234.5 as 1,234.50 € or 1 234,5.
设置项类型作用
Operation ChoiceThe calculation to perform. 21 options. 默认值:Add
Value ValueThe number to work on.
Second Value ValueThe second number, for Add, Subtract, Percentage and the rest.
Values ValueThe list of numbers, for Minimum, Maximum, Sum and Average.
Decimal Places NumberHow many decimal places Round keeps. 默认值:0
Format As ChoiceHow Format presents the number. Options: Plain number, Currency, Percentage. 默认值:Plain number
Locale TextLanguage tag deciding separators, such as en-US or fr-FR.
Currency TextThree-letter currency code, used when formatting as currency. 默认值:USD
Minimum Decimals NumberFewest decimal places Format shows. 默认值:0
Maximum Decimals NumberMost decimal places Format shows. 默认值:2
Whole Number ToggleWhether Random returns a whole number. 默认值:On
Put Result In Field TextName of the field holding the answer. 默认值:result
Include Input Fields ToggleKeep the incoming item’s fields alongside the answer. 默认值:On
  • Value: usually an expression such as {{ $input.price }}. Left empty, Math uses the item’s value field.
  • Percentage of gives what share Value is of Second Value (25 of 200 is 12.5). Percentage change goes from Value to Second Value (80 to 100 is 25).
  • Values: point it at a list, such as {{ $input.price }} after Aggregate.
  • Random number picks between Value (default 0) and Second Value (default 1), both included.
  • Format As Percentage multiplies by 100: 0.25 becomes 25%. Leave Locale empty to follow the browser’s language. An unknown locale or currency falls back to plain formatting.
  • Output

The answer is in Put Result In Field, for example {{ $input.result }}. Format returns text; every other operation returns a number. With Include Input Fields on, the answer is added to the incoming item; off, the item holds only the answer. Minimum, Maximum, Sum and Average always return only the answer.

None. This node needs no connection and has no slots for other nodes.

  1. HTML Extract reads one item per product, each with a price field.
  2. Aggregate with Mode Individual fields collects every price into one list.
  3. Math with Operation Sum and Values {{ $input.price }}.
  4. A second Math with Operation Format, Value {{ $input.result }}, Format As Currency, Currency EUR and Locale fr-FR gives text such as 1 234,50 €.
  • “The value is missing, not a number.” or “The value is empty, so there is nothing to calculate with.” The field you pointed at does not exist or is blank on this item. Check the expression in Value, or remove the item first with Filter.
  • “The value “19,99 €” is not a number.“ Text with a currency sign or a decimal comma is not a number. Clean it first with Regex or Text / Formatter.
  • “Cannot divide by zero.” (also for Remainder, Percentage of and Percentage change from zero). The second number, or the starting number for a change, is 0. Filter out those items first.
  • Sum or Average gives each item its own value instead of a total. The numbers arrive as separate items. Collect them into one list with Aggregate and point Values at it.
  • Round down gives -3 for -2.5. Round down always goes lower. Use Drop decimals to get -2.
  • Aggregate: collect values into one list before Sum or Average.
  • Edit Fields: set fields with simple expressions.
  • Sort: find the top or bottom items, not just the value.
  • Code: for calculations no operation covers.
编辑此页

最近更新:

Was this page useful?
向 Aria 询问“Math”