i have two one-to-may related layers (relation name: tree_observation
) parent: trees
and child: obeservations
. The trees should be revisited on a regular base and for each observation a new child feature should be created. I set up the child layer with fields "treeID" (=connecting field), "Date" and "Employee" - date auto fills with the current date, employee is filled by the user doing the observation.
In the parent layer, i want to create a virtual field "last_observation_done_by" where the employee name who did the last observation should appear.
This is causing me trouble. I set up the virtual field this way:
aggregate(layer:='observations',aggregate:='concatenate',expression:="Employee",filter:=maximum("Date"))
-> in my understanding, this should only give the name of the employee of the latest observation, but only returns NULL
Another approach was to work with relation_aggregate
:
relation_aggregate('tree_observation','concatenate',"Employee")
but it seems to lack a filter function. Is there any other way to get the employee name of the latest observation from the child layer into my parent layer?
trees
andobservations
, but the sample code is passingobservation
(singular, not plural). Is the sample code correct or your text description? What field(s) relate the parent and child tables?