[GIS] QGIS joins 2 FIELDS

attribute-joinsconditionalfields-attributesqgis

I have an excel with 4 columns (Region; District; village; number of cases)
Have a shapefile with dots for villages with many columns including (Region ; District ;Village)

I want to plot the cases of the excel (as dots on the villages) by joining the excel file and the shapefile.

The problem is that there are many villages (1000 in total) and many of them have the same name, but belong to different districts. The names of the districts are unique.

Therefore, I would need to join by 2 fields, (not only by village, but , by village and by district). I would need to join excel and shapefile by the fields "District" and " village" so the new column "cases" in created in the shapefile attributes table. I wonder HOW IS THAT DONE?? In QGIS I have learnt to join by 1 field (village), but if I add a second join (district) I lose many of my cases.

Is there a way QGIS can do that? Do I need to make some conditional or something?

Best Answer

The key here is to make two fields into one. Like lot and plan becomes lotplan (eg. Lot 10 on SP1234 -> 10/SP1234) in BOTH tables.. then join as normal. This is easy in Excel by adding a new header cell and use the function =A1 & "\" & B1 (or whatever you cells are) and then use field calc in QGIS. – Michael Miles-Stimson