In my project I have a many-to-one relationship.
For example I have a vector layer "Towns" and a data layer "TownsInfo".
Each town record consists of "Name" and "Id". Each TownsInfo record consist of "Id", "TownId", "Population" and "Source".
I want to show "Population" of town as label where "Source" is 'Wikipedia' for example.
How can I use "Population" and "Source" attributes from "Towns" expression builder?
Update 1
I've meant getting information only from records where "Source" is 'Wikipedia'
Answer
I've found out a solution.
I've made rule-based filtering with expression:
relation_aggregate( 'TownsInformationRelation', 'max', CASE WHEN "Source" = 'Wikipedia' THEN "Population" ELSE 0 END )
And also I've used filter:
relation_aggregate( 'TownsInformationRelation', 'count', CASE WHEN "Source" = 'Wikipedia' THEN 'true' ELSE NULL END )
Thanks!
No comments:
Post a Comment