Binary.Length
BinaryReturns the number of bytes in a binary value.
Syntax
Binary.Length(binary as nullable binary) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
binary | binary | Yes | The binary value whose length (in bytes) to return. |
Return Value
number — The 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
LenApplied Steps
Returns the length of the binary value, which is 11 bytes.
Value | |
|---|---|
| 1 | 11 |
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 | |
|---|---|---|
| 1 | Hello | 5 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks