Binary.ApproximateLength

Binary

Returns the approximate length of a binary value, or an error if the data source does not support approximate length.

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

Syntax

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

Parameters

NameTypeRequiredDescription
binarybinaryYesThe binary value whose approximate length to return.

Return Value

numberThe approximate number of bytes in the binary value.

Remarks

Binary.ApproximateLength returns an estimate of the number of bytes in a binary value. Unlike Binary.Length, which may need to fully evaluate a stream to determine its exact size, this function can return a result without reading all bytes. Not all data sources support approximate lengths — if the source cannot provide one, an error is raised.

This function is useful in scenarios where you need a quick size check without the cost of fully materializing a binary stream, such as when deciding whether to buffer content into memory.

Examples

Example 1: Get the approximate length of a binary value

let
    Source = Binary.FromText("i45WMlSKjQUA", BinaryEncoding.Base64),
    ApproxLen = Binary.ApproximateLength(Source)
in
    ApproxLen
Applied Steps

Returns the approximate length of the binary value, which is 9 bytes.

Value
19

Compatibility

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