Create a calculated field in a query

You can create a new field that displays the results of a calculation you define with an expression or that manipulates field values.

  1. Open the query in Design view.
  2. Type an expression in an empty cell in the Field row. If the expression includes a field name, you must place brackets around the name.

    Type brackets around field names in an expression

    After you press ENTER or move to another cell, Microsoft Access enters the default field name ExprN, where N is an integer incremented for each new expression field in the query. The name appears before the expression and is followed by a colon. In a datasheet, this name is the column heading.

    The expression's default field name is Expr1 which you can changed

    You can select ExprN and type a more descriptive name, such as NewPrice.

  3. If the expression includes one or more aggregate functions (Sum, Avg, Count, Min, Max, StDev, or Var), and if the design grid includes another field or fields that you want to use for grouping, click Totals on the toolbar (unless the Total row is already displayed). Leave Group By in the Total cell for the grouping field, and in the calculated field, change Group By to Expression.

    Add Group By and Expression in the Total row to group records

  4. If you want, enter criteria to affect results of the calculation.

    How?

    In the query design grid, where you specify criteria determines when the calculation is performed and can produce different query results.

    Note   Although the following examples only show queries that calculate totals, these guidelines apply to calculated fields as well.

    Limit groups before performing calculations on groups of records

    Return selected results after calculations are performed

    Limit records before they are grouped and before the calculation is performed

Notes