Byte.From

Number

Converts a value to an 8-bit unsigned integer (0 to 255).

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

Syntax

Byte.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number

Parameters

NameTypeRequiredDescription
valueanyYesThe value to convert. Accepts number, text, logical, or null.
culturetextNoAn optional culture string for locale-aware parsing of text values (e.g., "en-US").
roundingModenumberNoAn optional rounding mode constant (e.g., RoundingMode.AwayFromZero) used when truncating fractional values.

Return Value

numberAn 8-bit unsigned integer in the range 0–255.

Remarks

Byte.From converts a value to a byte — an 8-bit unsigned integer spanning the range 0 to 255. This is distinct from Int8.From, which produces a signed 8-bit integer covering -128 to 127. Values outside the 0–255 range raise an error at runtime, so validate or clamp inputs before calling this function when working with untrusted data.

Fractional numbers are rounded before conversion. By default the function uses round-half-to-even (banker's rounding), which differs from the conventional "round half up" behavior. If you need traditional rounding — for example, 2.5 → 3 — pass RoundingMode.AwayFromZero as the third argument. Text values are parsed as decimal numbers first. A logical true converts to 1, false to 0, and null returns null.

The byte type is most commonly encountered when working with binary data streams, raw byte buffers, or low-level protocol fields. In most Power Query data transformation work you will use Int64.From (Whole Number) or Decimal.From instead. Use Byte.From explicitly when a downstream system requires values annotated with the 8-bit unsigned type — for example, when building typed table schemas for custom connectors that interface with byte-array columns.

To apply the byte type across an entire table column, use Table.TransformColumnTypes with Byte.Type.

Examples

Example 1: Convert an integer within range

Byte.From(200)
Result
Result
1200

Example 2: Parse a text string as a byte

Byte.From("128")
Result
Result
1128

Example 3: Rounding behavior — default vs. away-from-zero

#table(
    {"Input", "Default (Banker's)", "AwayFromZero"},
    {
        {10.5, Byte.From(10.5), Byte.From(10.5, null, RoundingMode.AwayFromZero)},
        {11.5, Byte.From(11.5), Byte.From(11.5, null, RoundingMode.AwayFromZero)}
    }
)
Result
Input
Default (Banker's)
AwayFromZero
110.501011
211.501212

Compatibility

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