4

In a group of points where i am using the cluster symbol to indicate the number of close points, I would instead like to have the value from another field as the display number. For example points A1-A6 have the same lat/long, and the cluster symbol would display say the number 6.

If it can display the sum of the frequency column (i.e. 13) instead, what would I type in the font marker the expression string builder to achieve this?

Table example

1 Answer 1

5

The sum()-function does exactly what you need.

It sums up any expression, if needed grouped and/or filtered for additional conditions.

Basically you'd use sum("Freq") - this returns the total sum of the column "Freq". This can be grouped by an additional expression. If you had a separate column for your group, you simply hand over that column, e.g. sum("Freq","groupfieldname").

Since your group-designations are only part of your feature-IDs, you need to extract the group first. Assuming that your groups only run from A through Z, you can use left("Point",1) - this returns a string with the length of one character counted from the left of your feature-ID.

Mash it together:

sum("Freq",left("Point",1))

Now you get the sums of you "Freq"-field grouped by their ... well... group.

5
  • 1
    Erik, If i used sum("Freq") it returns the sum of the whole Freq column, not the clustered points. Nov 15, 2021 at 8:50
  • 2
    I suggest you read the whole answer, thank you @user16812309.
    – Erik
    Nov 15, 2021 at 9:21
  • Thankyou Erik, I have followed through with grouping my points and your answer works well for some points, but some others weirdly have a incorrect number. For example, where two points cluster and one has an sum value of 10, some show the correct amount, but another will show a sum value of 18046. Im still working on it. Nov 17, 2021 at 6:37
  • Please provide example data of a faulty group @user16812309
    – Erik
    Nov 17, 2021 at 8:17
  • 1
    Erik, issue resolved by checking the data. In cells where there was a 'null', for freq instead of a number, the sum would be weird. Removing the nulls solved the issue. The nulls should have been a 1 anyway. THankyou. I hate qgis a bit less today. Nov 18, 2021 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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