Action.Sequence

Action.Sequence is a Power Query M function that creates an action that executes a sequence of actions or functions in order. These actions are executed in sequence, with each subsequent action only executing after all previous actions have completed. The sequence can also handle functions, either with 0 or 1 argument, that return an action. The result of Action.Sequence is the result of executing the last element.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Action.Sequence( actions as list ) as any

Description

Creates an action that executes the sequence of elements in actions in order.

Each element of actions is either an action or a function that returns an action. An element in the list is executed only after all of the elements preceding it in the list are executed. In the case of an element that is a function, “executed” means that the function is evaluated and the action it returns is executed.

If an element of the list is a function then it must be either a 0 or 1-argument function that returns an action. The result of the execution of the preceding element is provided as the input to the function if it is a 1-argument function. The initial result (i.e. the result available to the first function in the sequence) is null.

Any element in the list that depends on a side effect or result of executing a preceding element must be expressed using a function.

The result of Action.Sequence is the result of executing the last element in the list (or null if the sequence is empty).

NOTE: A function in the list is not guaranteed to observe the side effects from the execution of the preceding elements in the list if the function references variables declared outside of its body (due to capture of free variables when the function is constructed). To ensure that updated data is observed by the function after an earlier element in the list executes, use an expression or function that directly accesses the affected data sources.

Examples

Creates an action that, when executed, will execute the first action ( which returns "hello" ), combine its result with the string "world!" to create a second action, and then execute the second action to produce a result of "hello world!".

Action.Sequence( {
    Action.Return( "Hello" ),
    ( result ) => Action.Return( result & " " & "world!" )
} )

Other functions related to Action.Sequence are:

BI Gorilla Blog

Last update: August 17, 2023 | Contribute » | Contributors: Rick de Groot
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.