[QGIS-Developer] QGIS expression to get internal ID of a feature in a related layer
Andreas Neumann
a.neumann at carto.net
Wed Nov 30 08:06:30 PST 2022
Hi Stefan,
I got it work with "aggregate()" not with "relation_aggregate()"
Not sure if relation_aggregate() works in both directions?
I also got a warning "The generated relations for a polymorphic relation
cannot be used" ...
I have inheritance in my data model - maybe that is the cause that
relation_aggregate() doesn't work, while aggregate works.
------------
Here is what works for me:
with_variable(
'vereinbarung',
get_feature(
'Vereinbarung',
't_id',
vereinbarung
),
aggregate(
layer:='Vereinbarung',
aggregate:='array_agg',
expression:=@id,
filter:=t_id = attribute(@vereinbarung,'t_id')
)[0]
)
'Vereinbarung' is a geometry layer in my project that is related to a
no-geometry table from which I want to trigger an atlas rendering ...
It is a pity that a "feature" doesn't contain it's internal ID in the
attributes ... it would make it much easier! No silly workarounds with
aggregates to get access to an internal id ...
Thanks a lot for the idea with the aggregates!
Andreas
On 2022-11-29 16:54, Stefan Giese (WhereGroup) via QGIS-Developer wrote:
> Hi Andreas,
>
> in case of a relation 1:many you can use the _relation_aggregate_
> function, something like:
>
> _ relation_aggregate('test_n_318_fk_test1_7993_id','concatenate',__
> to_string(@id),',')_
>
> where the first parameter is the ID of the relation.
>
> Hope this helps...
> Stefan
>
> Am 29.11.2022 um 15:05 schrieb Andreas Neumann via QGIS-Developer:
>
>> Hi,
>>
>> I am looking for a way to find out the internal id of a related layer
>> with a QGIS expression.
>>
>> @id and $id only work directly on the feature of the source layer, but
>> not on related layers.
>>
>> attributes(
>> get_feature(
>> 'Other Related Layer',
>> 't_id',
>> fkey_value
>> )
>> )
>>
>> doesn't contain the internal id of the other layer ...
>>
>> Any ideas how to get access to internal ids of other layers?
>>
>> Thank you and greetings,
>>
>> Andreas
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> --
> Mit freundlichen Grüßen
> Stefan Giese
> Projektleiter/Consultant
> ----------------------
> Where2B Konferenz 2022
> 15. Dezember 2022 in Bonn und Online
> where2b-conference.com
> -----------------------
> WhereGroup GmbH
> Schwimmbadstr. 2
> 79100 Freiburg
> Germany
>
> Tel.: +49 (0)761 / 519 102 - 61
> Fax: +49 (0)761 / 519 102 - 11
>
> stefan.giese at wheregroup.com
> www.wheregroup.com [1]
> Geschäftsführer:
> Olaf Knopp, Peter Stamm
> Amtsgericht Bonn, HRB 9885
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Links:
------
[1] http://www.wheregroup.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20221130/08f41630/attachment.htm>
More information about the QGIS-Developer
mailing list