Value.ReplaceType

Value

Replaces the type metadata of a value without converting the value itself.

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

Syntax

Value.ReplaceType(value as any, type as type) as any

Parameters

NameTypeRequiredDescription
valueanyYesThe value whose type metadata to replace.
typetypeYesThe new type to assign. This replaces the metadata but does not convert the value.

Return Value

anyThe original value with its type metadata replaced by the specified type.

Remarks

Value.ReplaceType replaces the type metadata attached to a value without performing any conversion. The underlying data remains unchanged — only the type annotation is updated. This is commonly used to:

- Assign a custom record type with field-level documentation to a record or table row. - Attach function type metadata (parameter names, descriptions) to custom functions. - Override the inferred type of a table to provide more specific column type information.

Important: This does not convert or validate the value. If you assign an incompatible type, the value may cause errors downstream when the type is checked.

Examples

Example 1: Assign a custom record type to a Sales row

let
    FirstRow = Table.First(Table.SelectColumns(Table.FirstN(Sales, 1), {"CustomerName", "Product", "Region"})),
    CustomType = type [CustomerName = text, Product = text, Region = text],
    Typed = Value.ReplaceType(FirstRow, CustomType),
    IsMatch = Value.Is(Typed, CustomType)
in
    #table(
        {"CustomerName", "Product", "Region", "TypeAssigned"},
        {{Typed[CustomerName], Typed[Product], Typed[Region], Text.From(IsMatch)}}
    )
Result
CustomerName
Product
Region
TypeAssigned
1AliceWidget AEasttrue

Compatibility

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