3

I have a point geometry layer called 'PORTA' that representing the entrances of the houses.

On the other hand, I have a attribute table called 'NUCLEUS' that represent the addresses that are inside every houses.

The 'PORTA' layer and the 'NUCLEUS' table have a common field: "RFP" for the 'PORTA' layer and "RFN" for the 'NUCLEUS' table.

The relationship would be 1-n for layer 'PORTA to 'NUCLEUS' table.

I show a screenshot of QGIS workspace I am working with a simplified dataset, as I show he geometry layer and the table:

enter image description here

For my project I would like to use two label expressions:

  • Expression 1: For each point of layer 'PORTA', count the addresses that are in table 'NUCLEUS'. That is, count the attributes of field "RFN" of 'NUCLEUS' table that share the same code with the field "RFP" of 'PORTA' layer.

  • Expression 2: Show the list of the values of field "RFN" of 'NUCLEUS' table.

I show a simulated screenshot for the expected goal:

enter image description here

1 Answer 1

4

Counting the no. of features of NUCLEUS with the same RFN value as the current point's RFP value:

with_variable(
    'rfp',
    RFP,
    aggregate(
        'NUCLEUS', 
        'count', 
        @id, 
        filter:=RFN=@rfp
    )
)

For the list of the values of field "name" from 'NUCLEUS' table, where RFN is the same value as RFP:

array_to_string (
    with_variable(
        'rfp',
        RFP,
        aggregate(
            'NUCLEUS', 
            'array_agg', 
            name, 
            filter:=RFN=@rfp
        )
    ),
    delimiter:= '\n' 
)

enter image description here

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.