BinaryFormat.Transform

Binary

Returns a binary format that transforms values read by another binary format.

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

Syntax

BinaryFormat.Transform(binaryFormat as function, function as function) as function

Parameters

NameTypeRequiredDescription
binaryFormatfunctionYesThe binary format used to read the value.
functionfunctionYesA function that receives the read value and returns the transformed value.

Return Value

functionA binary format function that reads a value and applies a transformation function to it.

Remarks

BinaryFormat.Transform returns a binary format that reads a value using the specified binaryFormat and then applies a transformation function to the result. This enables post-processing of binary data inline within a format definition.

The transformation function receives the raw value produced by binaryFormat and can return any type. This is useful for converting raw byte values into meaningful domain values, scaling numbers, mapping enumeration codes to text, or any other post-read processing.

This pattern keeps the parsing and transformation logic together within the format definition rather than requiring a separate processing step after reading.

Examples

Example 1: Read a byte and add one to it

let
    binaryData = #binary({1}),
    transformFormat = BinaryFormat.Transform(
        BinaryFormat.Byte,
        (x) => x + 1
    )
in
    transformFormat(binaryData)

Example 2: Convert a byte to a boolean

let
    binaryData = #binary({1}),
    boolFormat = BinaryFormat.Transform(
        BinaryFormat.Byte,
        (x) => x <> 0
    )
in
    boolFormat(binaryData)

Compatibility

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