List.Single
The one item of a list that must hold exactly one.
Group: List. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
List.Single(list as list) as any
| Parameter | Type | Description |
|---|---|---|
list | list | A list with one item. |
Returns
any. The list's only item.
Remarks
- An empty list and a list of two or more items are both errors.
List.SingleOrDefaultgives a default for the empty list instead.
Examples
The one matching shop
List.Single(List.Select({"Oslo", "Bergen"}, each Text.StartsWith(_, "B")))
"Bergen"
Two items is an error
List.Single({"Oslo", "Bergen"})
Result: an error.
[Reason = "Expression.Error", Message = "There were too many elements in the enumeration to complete the operation.", Detail = null]