Type.ListItem

Type

Returns the item type of a list type.

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

Syntax

Type.ListItem(type as type) as type

Parameters

NameTypeRequiredDescription
typetypeYesA list type to extract the item type from.

Return Value

typeThe type of items contained in the list type.

Remarks

Type.ListItem extracts the element type from a list type. For example, given the type type {number} (a list of numbers), Type.ListItem returns type number.

This is useful in advanced scenarios involving type introspection, such as building generic functions that need to understand the structure of their inputs.

If the input is not a list type, the function raises an error.

Examples

Example 1: Extract item type from a list type

let
    ListType = type {text},
    ItemType = Type.ListItem(ListType),
    IsText = Type.Is(ItemType, type text)
in
    #table({"ListType", "ItemType IsText"}, {{"type {text}", IsText}})
Result
ListType
ItemType IsText
1type {text}TRUE

Compatibility

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