Value.Optimize

Value

Returns an optimized form of the given value, hinting to the engine that query optimization should be applied.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Value.Optimize(value as any) as any

Parameters

NameTypeRequiredDescription
valueanyYesThe value to optimize.

Return Value

anyThe 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 1: Optimizing a primitive value returns the same value

Result
Result
142

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)
Applied Steps

The final output — counts the rows in the optimized table, confirming there are 3 rows with Quantity greater than 2.

Result
13

Example 3: Optimizing text — returns the same text

Value.Optimize("hello") = "hello"
Result
Result
1TRUE

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks