Performance issues styling

I have a styling that changes the color of a symbol when the task is set to ‘done’.

So in the data defined override, I added this expression:

if(

relation_aggregate(‘bomen_post_code_site_bomen_d34d_code_site’, ‘count’, “id_arb”) > 0
AND
relation_aggregate(‘bomen_post_code_site_bomen_d34d_code_site’, ‘sum’, if(“uitgevoerd”, 1, 0))

relation_aggregate(‘bomen_post_code_site_bomen_d34d_code_site’, ‘count’, “id_arb”),
color_rgb(134, 213, 60),
color_rgb(255, 0, 0)
)

In qgis this works perfect but in Qfield it gets really slow. Everytime I pan, it recalculates i think. Is there a solution the increase performance?

HI Tomas,
Great task :slight_smile:

Have you tried using a virtual layer instead or precalculating the colors in a new field? and then use this instead

Adding a new layer always comes as the last option because for the users this is can be confusing

You could create an additional field and use your expression as a default for this field. Then display the color based on this field. This way, the calculation isn’t performed every time the map is drawn, but only when an object is newly created or changed.

Please forget my suggestion. I just noticed that the change in the relation table doesn’t trigger the calculation of the default value in the main table.