Value.Type
ValueReturns the type of a value.
Syntax
Value.Type(value as any) as typeParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value whose type to return. |
Return Value
type — The type of the given value (e.g., Number.Type, Text.Type, Logical.Type).
Remarks
Value.Type returns the M type of a value. This is useful for inspecting column values at runtime, building dynamic logic based on value types, or debugging type-related issues. Common return types include Number.Type, Text.Type, Logical.Type, Date.Type, and Table.Type.
Note that Value.Type returns an opaque type value. To display it meaningfully, you typically compare it using Value.Is or convert it to a description string with metadata functions.
Examples
Example 1: Check types of Sales column values
let
FirstRow = Table.First(Sales),
TypeName = (val) =>
if Value.Is(val, type number) then "number"
else if Value.Is(val, type text) then "text"
else if Value.Is(val, type date) then "date"
else "other"
in
#table(
{"Column", "Value", "Type"},
{
{"OrderID", Text.From(FirstRow[OrderID]), TypeName(FirstRow[OrderID])},
{"CustomerName", FirstRow[CustomerName], TypeName(FirstRow[CustomerName])},
{"UnitPrice", Text.From(FirstRow[UnitPrice]), TypeName(FirstRow[UnitPrice])},
{"OrderDate", Text.From(FirstRow[OrderDate]), TypeName(FirstRow[OrderDate])}
}
)Result
Column | Value | Type | |
|---|---|---|---|
| 1 | OrderID | 1 | number |
| 2 | CustomerName | Alice | text |
| 3 | UnitPrice | 25 | number |
| 4 | OrderDate | 1/15/2024 | date |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks