2

Using QGIS, my goal is to group "FSA"s (postal code or zip code ordering) into larger regions, and have data labels labelling these larger regions. The labels themselves would be the sum of measured values (in this case registered vehicles) pertaining to the "FSA"s.

For example, the larger region K0 consists of "FSA"s K0A, K0B, K0C, etc; and the label for the K0 region would equal the sum of registered vehicles for all the K0#s in the category. I'm more than happy to use conditional symbology to express the registered vehicle values as well, but in either case I don't know how to tell QGIS to use the summed data per larger region.

Attribute Table

Currently the expression I've built reads as follows:

aggregate(
    layer:='Ontario FSA shp',
    aggregate:='sum',
    expression:="MTO heat map_Total BEVs",
    filter:="MTO heat map_Grouping"=K0
    )

You can probably tell I'm not an expert, but have been using some of the example expressions as a baseline. The current expression returns all labels as '0'.

map labels

2
  • At the first glance maybe K0 should be 'K0' (with apostrophes)?
    – Hjall
    May 5, 2022 at 7:15
  • 1
    As per the help center please do not include chit chat like statements of appreciation within your posts.
    – PolyGeo
    May 5, 2022 at 8:31

1 Answer 1

1

Use QGIS expressions with the aggregate function sum(), grouping it by the common part of the "CFSAUID" attribute. For this, define an expression that returns this common part, here returning the first two characters with left (CFSAUID, 2).

So the whole expression looks like:

sum(value, group_by:=left(CFSAUID,2))

enter image description here

1
  • Hi Babel, thank you for this. I'll test this out and see if I can get the desired result. May 5, 2022 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.