Binary.Length

Binary

Returns the number of bytes in a binary value.

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

Syntax

Binary.Length(binary as nullable binary) as nullable number

Parameters

NameTypeRequiredDescription
binarybinaryYesThe binary value whose length (in bytes) to return.

Return Value

numberThe number of bytes in the binary value.

Remarks

Binary.Length returns the exact number of bytes in a binary value. Unlike Binary.ApproximateLength, this function fully evaluates the binary stream to determine its precise size.

For streaming binary values where you only need a rough size estimate, consider using Binary.ApproximateLength instead to avoid materializing the entire stream.

Examples

Example 1: Get the length of a binary value

let
    Source = Binary.FromList({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}),
    Len = Binary.Length(Source)
in
    Len
Applied Steps

Returns the length of the binary value, which is 11 bytes.

Value
111

Example 2: Get the length of text converted to binary

let
    TextVal = "Hello",
    AsBinary = Binary.From(TextVal),
    ByteLength = Binary.Length(AsBinary)
in
    #table({"Text", "ByteLength"}, {{TextVal, ByteLength}})
Applied Steps

The final output — a single-row table showing the text and its byte length.

Text
ByteLength
1Hello5

Compatibility

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