Value.Optimize
ValueReturns an optimized form of the given value, hinting to the engine that query optimization should be applied.
Syntax
Value.Optimize(value as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to optimize. |
Return Value
any — The value in an optimized form as determined by the engine.
Remarks
Value.Optimize is an engine hint function — it signals to the Power Query evaluation engine that the given value should be evaluated using optimized strategies. The function returns a value that is semantically identical to the input, but the engine may use different internal evaluation paths such as query caching, enhanced query folding, or parallel execution.
For end users, Value.Optimize has no observable effect on the data returned. It is primarily used in custom connector development as an explicit performance hint — for example, to encourage the engine to cache or fold an intermediate result before additional operations are applied. Microsoft's official connector development SDK documentation discusses scenarios where Value.Optimize is appropriate.
In practice, calling Value.Optimize in user-written M queries is rarely beneficial and can safely be omitted. The Power Query engine applies its own optimization passes automatically. Treat this function as an advanced tool for connector authors rather than a general-purpose performance knob.
Examples
Example 2: Optimizing a filtered table — data is unchanged
let
Filtered = Table.SelectRows(Sales, each [Quantity] > 2),
Optimized = Value.Optimize(Filtered)
in
Table.RowCount(Optimized)The final output — counts the rows in the optimized table, confirming there are 3 rows with Quantity greater than 2.
Result | |
|---|---|
| 1 | 3 |
Example 3: Optimizing text — returns the same text
Value.Optimize("hello") = "hello"Result | |
|---|---|
| 1 | TRUE |