Calculate a new field

10 minutes

For the exercise on the following page, we want to visualise quantitative, or numerical, data. The water beetle doesn’t contain appropriate numerical data, so we need to calculate a new field first

  • If you’re working with your own field data and it already contains quantitative data such as number of individuals sighted or tree diameter, you can omit the exercise below and go straight to the next page
  • If you’re working with the water beetle example data, we’re going to extracting year from our date field using the QGIS field calculator
  1. Turn on the ability to edit your layer - right-click Toggle Editing
  2. Open the attribute table in the usual way, and find the open the field calculator (Ctrl+I) button in the toolbar of editing buttons at the top of the Attribute table
  3. Type your new field name (Year for the water beetle dataset) into Output field name
  4. In the central list of variables, expand Date and Time
  5. Scroll down the list of function and double-click on year to enter it into the Expression (centre-left of dialogue box)
  6. In the central list of variables, expand Fields and Values
  7. Double-click on Date to add it to your Expression
  8. Type in a closing parenthesis ) at the end of the Expression using your keyboard
  9. Click OK to calculate the new field
  10. Note the presence of your new Year field in the attributes table
  11. Close the attribute table and right-click Toggle Editing off
  12. Save your changes when prompted

  • Turn on the ability to edit your layer - right-click Toggle Editing
QGIS screenshot: Toggle editing on


  • Open the attribute table in the usual way, and find the open the field calculator (Ctrl+I) button in the top toolbar of editing buttons
QGIS screenshot: Open field calculator


  • Type your new field name (Year for the water beetle dataset) into Output field name
QGIS screenshot: Type field name


  • In the central list of variables, expand Date and Time
QGIS screenshot: Expand Date and Time


  • Scroll down the list of function and double-click on year to enter it into the Expression (centre-left of dialogue box)
QGIS screenshot: Select year


  • In the central list of variables, expand Fields and Values
QGIS screenshot: Expand Fields and values


  • Double-click on Date to add it to your Expression
QGIS screenshot: Select Date


  • Type in a closing parenthesis ) at the end of the Expression using your keyboard
QGIS screenshot: Close expression


  • Click OK to calculate the new field
QGIS screenshot: Click OK


  • Note the presence of your new Year field in the attributes table
QGIS screenshot: View new field


  • Close the attribute table and right-click Toggle Editing off
QGIS screenshot: Toggle editing off


  • Save your edits when prompted
QGIS screenshot: Save edits



Previous submodule:
Next submodule: