I have a polygon layer with a Value Relation field that I'm using to capture upstream catchment areas that contribute to the selected record.

An example would be if I had 3 polygons of 100m2 - so I have 3 records in my table with a geometry area of 100m2. But polygons A & B contribute to the catchment area of polygon C, so I use the Value Relation field to identify A & B as contributors to C. I use the Value column to identify the polygon, but I use the Key column to save the area geometry values in the column. I then want to add a virtual field to calculate the sum of the values in the Value Relation field and add it to the area of the particular record. In this case, I would have a virtual field of 300m2.

The problem I'm having is summing the values of the Value Relation field (Real) - as soon as I save the table, I lose the values in the Value Relation field. Everything becomes zero.

I've been trying with the "UP_AREA" field as both a text and as a double. The text values seem to remain in the table, but the doubles are not showing up. In the screen shot at the bottom, you can see that the AREA_ha values are being saved, but I'm not able to convert to real.

The last screenshot below shows that the values appear as expected in the UP_AREA_D field as expected when the polygon is drawn, but as soon as I save the table, the field returns to null.

Open to any and all suggestions if anyone has a better way to do this.

Table fields

Value Relation settings

Table Records

Virtual Field Setings

Before Table save

  • So "UP_AREA" is the value relation column? Can we see what the values look like in this column before you save the layer and they disappear? – csk Dec 19 '18 at 17:07
  • I've updated the screenshots above, the values are staying in the table if I change the field data type to string, however, I'm not able to convert to real within my expression... – CEL-ma Dec 19 '18 at 17:20
  • 1
    The values aren't staying because they're not the correct data type. A double type cell can't store a list of numbers. – csk Dec 19 '18 at 17:23
  • 1
    The sum() function can't take a list of numbers as input. If you want to use the sum() function, you have to figure out an aggregate expression that does the same thing as the value relation column. – csk Dec 19 '18 at 17:36

Your Answer

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

Browse other questions tagged or ask your own question.