Value.Metadata
ValueReturns the metadata record associated with a value.
Syntax
Value.Metadata(value as any) as recordParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value whose metadata record is returned. |
Return Value
record — The metadata record attached to the value, or an empty record if none exists.
Remarks
In Power Query M, every value can carry an associated metadata record — an auxiliary record of key-value pairs attached to the value without affecting its underlying data or equality. Metadata is attached using the meta keyword: value meta [Key = "value"].
Value.Metadata retrieves this metadata record. If the value has no metadata, an empty record ([]) is returned — never null.
Key behaviors of metadata in M:
- Transparent to equality: 1 meta [Tag = "x"] is equal to 1. Metadata does not affect the = operator, Value.Equals, or type checks.
- Lost on operations: most M operations discard metadata from their inputs. For example, (1 meta [Tag = "x"]) + 1 returns 2 with no metadata. Metadata must be explicitly re-attached if needed after transformations.
- Used by the engine: Power Query uses metadata internally to carry display format strings, column descriptions, and data source information. You can read this engine metadata with Value.Metadata.
The companion functions are Value.ReplaceMetadata (to set or replace metadata) and Value.RemoveMetadata (to strip it). The meta keyword expression v meta r is equivalent to Value.ReplaceMetadata(v, r).
Examples
Example 1: Retrieve metadata attached with the meta keyword
Value.Metadata(1 meta [Source = "Sales", Verified = true])Name | Value | |
|---|---|---|
| 1 | Source | Sales |
| 2 | Verified | true |
Example 3: Access a specific field from the metadata record
let
Annotated = "hello" meta [Language = "en", Source = "Config"],
Meta = Value.Metadata(Annotated)
in
Meta[Language]The final output — accesses the Language field from the metadata record, returning "en".
Result | |
|---|---|
| 1 | en |