Int16.From
NumberConverts a value to a 16-bit signed integer (-32,768 to 32,767).
Syntax
Int16.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert. Accepts number, text, logical, or null. |
culture | text | No | An optional culture string for locale-aware parsing of text values. |
roundingMode | number | No | An optional rounding mode constant used when truncating fractional values. |
Return Value
number — A 16-bit signed integer in the range -32,768 to 32,767.
Remarks
Int16.From converts a value to a signed 16-bit integer (also called a "short integer"), covering the range -32,768 to 32,767. Values outside this range cause a runtime error. Fractional numbers are rounded before conversion; the default rounding mode is round-half-to-even (banker's rounding), not the conventional "round half up." Pass RoundingMode.AwayFromZero to match the rounding behavior you may expect from Excel or school arithmetic.
In database terms, this type maps to SMALLINT in SQL Server and many other databases. It is more compact than Int32 (32-bit) and substantially more compact than Int64 (64-bit). Use Int16.From when your source or destination system explicitly uses a 16-bit integer type and you need to match that schema precisely.
For most data transformation work, prefer Int64.From (the Whole Number type in Power BI) unless you have a specific reason to constrain values to 16 bits. Text values are parsed numerically; logical true converts to 1, false to 0, and null returns null.
Examples
Example 1: Convert a number within range
Int16.From(1000)Result | |
|---|---|
| 1 | 1,000 |
Example 2: Convert the maximum Int16 value from text
Int16.From("32767")Result | |
|---|---|
| 1 | 32,767 |
Example 3: Rounding — default banker's rounding vs. away-from-zero
#table(
{"Input", "Default (Banker's)", "AwayFromZero"},
{
{100.5, Int16.From(100.5), Int16.From(100.5, null, RoundingMode.AwayFromZero)},
{101.5, Int16.From(101.5), Int16.From(101.5, null, RoundingMode.AwayFromZero)}
}
)Input | Default (Banker's) | AwayFromZero | |
|---|---|---|---|
| 1 | 100.50 | 100 | 101 |
| 2 | 101.50 | 102 | 102 |