List.Single

List.Single is a Power Query M function that returns the single item in a list if the list contains only one item, otherwise it throws an exception. The function returns either the single item or an error.

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

Syntax

List.Single( list as list ) as any

Description

If there is only one item in the list list, returns that item. If there is more than one item or the list is empty, the function throws an exception.

Examples

Find the single value in the list {1}.

// Output: 1
List.Single( {1} )

Find the single value in the list {1, 2, 3}.

// Output: [Expression.Error] There were too many elements in the enumeration to complete the operation.
List.Single( {1, 2, 3} )

Other functions related to List.Single are:

BI Gorilla Blog

Last update: August 25, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/list-single
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.