Binary.From

Binary

Converts a value to its binary representation.

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

Syntax

Binary.From(value as any, optional encoding as nullable number) as nullable binary

Parameters

NameTypeRequiredDescription
valueanyYesThe value to convert to binary.
encodingnumberNoThe text encoding to use when converting text values (e.g., TextEncoding.Utf8).

Return Value

binaryThe binary representation of the given value.

Remarks

Binary.From converts a value to its binary representation. When the input is text, it encodes the text using the specified encoding (defaulting to UTF-8). When the input is already binary, it is returned as-is.

This function is useful when you need to prepare content for POST requests with Web.Contents, or when working with binary data transformations.

Examples

Example 1: Convert text to binary and back

let
    TextValue = "Hello, World!",
    AsBinary = Binary.From(TextValue),
    AsBase64 = Binary.ToText(AsBinary, BinaryEncoding.Base64)
in
    #table({"Input", "Base64"}, {{TextValue, AsBase64}})
Result
Input
Base64
1Hello, World!SGVsbG8sIFdvcmxkIQ==

Compatibility

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