<!-- https://learnsql.cpetoday.com/functions/m/record-addfield -->
# Record.AddField

Language: Power Query M
Category: Record
Syntax: Record.AddField(record, fieldName, value, optional delayed)
Summary: Returns a copy of a record with one new field added.
Returns: A new record with the extra field.
Level: Intermediate
Related: Record.RemoveFields, Record.SelectFields, Record.RenameFields, Record.Combine, Record.TransformFields

## What it does
Record.AddField returns a copy of a record with one more field. The original record is not changed. Use it to attach a label or a calculated value to a row, such as a source file name, an entity code or a computed total, before the row goes into a list or a table.

## Syntax and arguments
- `record`: the record to extend.
- `fieldName`: the name of the new field, as text.
- `value`: the value to store in it.
- `delayed` (optional): when true, the value is calculated only when it is used. Leave it out for ordinary values.

## Example
A bank statement has been read into a record for each month, and the team wants each record to carry the entity it belongs to, so the rows can be combined later.

```powerquery
let
    MonthRecord = [Period = "2026-03", Closing = 15940],
    Tagged = Record.AddField(MonthRecord, "Entity", "Northwind US"),
    Fields = Record.FieldNames(Tagged)
in
    Tagged
```

`Tagged` is the record with three fields: Period, Closing and Entity. The original `MonthRecord` still has only two.

## Example: a second, different use
Adding a calculated field to a row: `Record.AddField(Row, "Variance", Row[Actual] - Row[Budget])` gives the row a variance field.

## Things to watch
- If the field already exists, the function fails. Check with Record.HasFields first.
- Adding a field to a record does not change the table it came from. For a table, use Table.AddColumn.
- Keep the field name short and clear. It becomes a column name later.
- The delayed option is rarely needed in finance queries.

## In business terms
Tagging rows with entity, source or period before combining files lets the reviewer trace every line back to its file. A tag is cheap to add and very useful when a total does not agree.
