Text.Length

Text

Returns the number of characters in a text value.

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

Syntax

Text.Length(text as nullable text) as nullable number

Parameters

NameTypeRequiredDescription
texttextYesThe text value to measure.

Return Value

numberThe number of characters in the text.

Remarks

Text.Length returns the number of characters in a text value, including spaces and special characters. Returns null if the input is null.

Examples

Example 1: Get product name lengths

Table.AddColumn(
    Table.SelectColumns(Products, {"ProductName"}),
    "NameLength", each Text.Length([ProductName]), type number
)
Result
ProductName
NameLength
1Widget A8
2Gadget B8
3Widget C8
4Gadget D8
5Thingamajig E13

Compatibility

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