I just started to work with QGIS recently and am struggling with the following:
I have 1 a CSV table on offshore branches of certain institutions including info on their respective countries of origin. No geographical data except the columns with country names (
Home Country
,Host Country
).Here is an example of the table with the relevant columns:
Institution name | Institution Branch | Home Country | Host Country |
---|---|---|---|
xxx | xxx2 | Germany | Saudi Arabia |
yyy | yyy2 | Germany | India |
zzz | zzz2 | USA | India |
- I also have 2 a polygon layer with the world countries in which each country takes 1 row, and each with it's own polygon represented in the shapefile (the country name column is named
name
)
Both attribute tables use the same format for the country names.
Now I would like to
- add a field (column) to the 2 country layer's attribute table that counts for each country how many institutions have it as a
Home Country
in the CSV table. Using the above table as an example, the new column would count 2 for Germany, and 1 for USA. - add additional columns to the 2 country layer's attribute table that count for each country how many institutions have it as a
Home Country
in the CSV table AND have a branch in a certainHost Country
. For example in the above table I would like to only count for those countries with institutions with a branch inHost Country
= India. The resulting column should count 1 for Germany, and 1 for USA.