2

I have a survey form and some features (trees) will be grouped using the same "TreeNumber".

Hopefully, I can write an expression that means users only have to fill in most of the data for one feature, and the expression with fill in the gaps in another set of virtual fields for the other features.

So far I have tried the expression below which I hoped would return the maximum value from all the features filtered to match the current feature "TreeNumber" but it just crashes QGIS.

maximum("Species", "TreeNumber" = attribute($currentfeature, "TreeNumber"))
Taras
35.7k5 gold badges77 silver badges151 bronze badges
asked Nov 1, 2022 at 18:15

1 Answer 1

2

Try this expression:

with_variable(
 name:='currentTreeNumber',
 value:="TreeNumber",
 expression:=maximum(
 expression:="Species",
 filter:="TreeNumber"=@currentTreeNumber
 )
 )

$currentfeature inside an aggregate returns features of the aggregation, you can store the value of the field of interest of the current feature in a variable with the with_variable() function and then compare it with the value inside the aggregate.

Taras
35.7k5 gold badges77 silver badges151 bronze badges
answered Nov 1, 2022 at 20:34
1
  • Many thanks! I have to look at the help file for with_variable Commented Nov 2, 2022 at 20:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.