Value.Add
ValueReturns the sum of two values, with support for numbers, durations, and date/time types.
Syntax
Value.Add(value1 as any, value2 as any, optional precision as nullable number) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
value1 | any | Yes | The first value (number, duration, datetime, etc.). |
value2 | any | Yes | The second value to add. |
precision | number | No | Controls floating-point precision. Defaults to Precision.Double. |
Return Value
any — The sum of value1 and value2.
Remarks
Value.Add returns the sum of value1 and value2. It is the functional equivalent of the + operator in M — Value.Add(a, b) produces the same result as a + b.
This function supports type coercion across compatible types:
- number + number — standard numeric addition, returning a number.
- duration + duration — adds two durations together, returning a duration.
- datetime + duration — shifts a datetime forward by the given duration, returning a datetime.
- date + duration — shifts a date forward by the given duration, returning a date.
- time + duration — shifts a time forward by the given duration, returning a time.
- datetimezone + duration — shifts a datetimezone forward by the given duration, returning a datetimezone.
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.
If the two values are of incompatible types (e.g., text + number), an error is raised.
Examples
Example 1: Add numeric columns
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Sales, 5), {"OrderID", "Product", "UnitPrice"}),
"WithShipping", each Value.Add([UnitPrice], 5), type number
)Output
OrderID | Product | UnitPrice | WithShipping | |
|---|---|---|---|---|
| 1 | 1 | Widget A | 25 | 30 |
| 2 | 2 | Gadget B | 50 | 55 |
| 3 | 3 | Widget C | 15 | 20 |
| 4 | 4 | Gadget D | 75 | 80 |
| 5 | 5 | Widget A | 25 | 30 |
Example 2: Add a duration to a date
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Sales, 4), {"OrderID", "OrderDate"}),
"FollowUpDate", each Value.Add([OrderDate], #duration(30, 0, 0, 0)), type date
)Output
OrderID | OrderDate | FollowUpDate | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 2/14/2024 |
| 2 | 2 | 1/20/2024 | 2/19/2024 |
| 3 | 3 | 2/1/2024 | 3/2/2024 |
| 4 | 4 | 2/15/2024 | 3/16/2024 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks