Binary.From
BinaryConverts a value to its binary representation.
Syntax
Binary.From(value as any, optional encoding as nullable number) as nullable binaryParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert to binary. |
encoding | number | No | The text encoding to use when converting text values (e.g., TextEncoding.Utf8). |
Return Value
binary — The 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 | |
|---|---|---|
| 1 | Hello, World! | SGVsbG8sIFdvcmxkIQ== |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks