
Creating table joins
Let's say that you need to make a map of the total population by county. However, the counties' GIS layers do not have population as an attribute. Instead, this data is contained in an Excel spreadsheet. It is possible to join additional tabular data to an existing attribute table.
There are two requirements, which are as follows:
- The two tables need to share fields with attributes to match for joining
- There needs to be a cardinality of one-to-one or many-to-one between the attribute table and the standalone table
To create a join, load both the GIS layer and the standalone table into QGIS Desktop. QGIS will accept a variety of standalone table file formats including Excel spreadsheets (.xls and .xlsx), dBase (.dbf) files, and comma-separated value (.csv) files. You can load this tabular data using Layer | Add Layer | Add Vector Layer and setting the file type filter to All files (*) (*.*) as shown in the following screenshot:

Once the data is loaded, a join can be completed by following these steps:
- Select the GIS layer in the Layers panel that will receive the new data from the join.
- Navigate to Layer | Properties and choose the Joins tab.
- Click on the Add join button (the one with a green plus sign).
- Choose the Join layer, Join field, and Target field values. The Join layer and Join field values represent the standalone table. The Target field value is the column in the attribute table on which the join will be based.
- At this point, you can choose Cache join layer in virtual memory, Create attribute index on join field, or Choose which fields are joined. The last option allows you to choose which fields from the join layer to append to the attribute table. A new feature also allows you to set a Custom field name prefix. At this point, the Add vector join window will look like the following screenshot.
- Once created, the join will be listed on the Joins tab. The extra attribute columns from the Join layer will be appended to the attribute table, where the value in the Join field matches the value in the Target field.
- The additional data from the join can be used to query the data and style the data.
- Joins can be modified by selecting the join and clicking the pencil edit button. They can be removed by clicking on the remove join button (the one with a red minus sign).