Value.Divide
ValueReturns the result of dividing one value by another, with support for numbers and durations.
Syntax
Value.Divide(value1 as any, value2 as any, optional precision as nullable number) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
value1 | any | Yes | The dividend (number, duration, etc.). |
value2 | any | Yes | The divisor. |
precision | number | No | Controls floating-point precision. Defaults to Precision.Double. |
Return Value
any — The result of dividing value1 by value2.
Remarks
Value.Divide returns the result of dividing value1 by value2. It is the functional equivalent of the / operator in M — Value.Divide(a, b) produces the same result as a / b.
This function supports type coercion across compatible types:
- number / number — standard numeric division, returning a number.
- duration / number — divides a duration by a scalar, returning a shorter duration.
- duration / duration — divides two durations, returning a number (the ratio).
The optional precision parameter controls floating-point precision for numeric operations. By default, Precision.Double is used. You can specify Precision.Decimal for higher-precision decimal arithmetic.
Division by zero raises an error. If the two values are of incompatible types, an error is raised.
Examples
Example 1: Calculate unit price from total and quantity
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Sales, 5), {"OrderID", "Product", "UnitPrice", "Quantity"}),
"Computed", each Value.Divide([UnitPrice] * [Quantity], [Quantity]), type number
)Output
OrderID | Product | UnitPrice | Quantity | Computed | |
|---|---|---|---|---|---|
| 1 | 1 | Widget A | 25 | 4 | 25 |
| 2 | 2 | Gadget B | 50 | 2 | 50 |
| 3 | 3 | Widget C | 15 | 10 | 15 |
| 4 | 4 | Gadget D | 75 | 1 | 75 |
| 5 | 5 | Widget A | 25 | 2 | 25 |
Example 2: Divide a duration by a number
Value.Divide(#duration(10, 0, 0, 0), 4)Output
Result | |
|---|---|
| 1 | 2.12:00:00 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks