Table.ViewFunction

Table

Creates a view function that can be intercepted by a Table.View handler.

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

Syntax

Table.ViewFunction(function as function) as function

Parameters

NameTypeRequiredDescription
functionfunctionYesThe function to wrap so it can be intercepted by a Table.View OnInvoke handler.

Return Value

functionA wrapped function that can be handled by the OnInvoke handler in Table.View.

Remarks

Table.ViewFunction wraps a function so that it can be intercepted by the OnInvoke handler in a Table.View. This enables custom connectors to define their own foldable operations beyond the built-in set (filtering, sorting, column selection, etc.).

When the wrapped function is called on a view:

1. If the view has an OnInvoke handler and it handles the function, the handler's result is used. 2. If no OnInvoke handler exists, or it does not handle the function, or the handler raises an error, the original function is applied on top of the view as a fallback.

This function is primarily used by connector developers building advanced custom connectors. See the Power Query SDK Table.View documentation for examples.

Examples

Example 1: Define a custom foldable operation

let
    TopNByColumn = Table.ViewFunction((table as table, column as text, n as number) =>
        Table.FirstN(Table.Sort(table, {column, Order.Descending}), n)
    )
in
    TopNByColumn

Compatibility

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