1

I have a two csv tables that have been related to eachother (RelatedResults):

Table 1 = Locations which is loaded as points Which has the fields[ID] [Type] [X] [Y]

Example: Point_1, Frogs, LAT, LONG

Table 2 = Results which is loaded as just an attribute table Which has the fields [ID] [Year] [ResultA] [ResultB]

Example:

Point_1, 2017, 2000, 4000

Point_1, 2018, 6000,150

I am trying to label the points based upon the year of sampling and every time I try to do it will only label using the result from 2017.

I have tried:

Filter

relation_aggregate( 'RelatedResults', 'count', CASE WHEN "Year" = '2018' THEN 'true' ELSE Null END )

Label Expression Generator

attribute(get_feature('Results', 'ID', ID), 'ResultA')

Not sure what I am doing incorrectly to get this to work as it will only ever show "2000" from the first year of results.

Any help would be amazing guys :). I have been stuck on this for a couple of days now. I need to produce concentration contours across a large areas for each year going back to 1985...

3
  • You can probably do it your way, but why no be free as a bird and use sql in a virtual layer: select t1.x,t1.y, t1.geometry, t2.year from table1 t1 inner join table2 t2 using (id). Assuming you have geometry in table1. BTW x is long not lat.
    – Jakob
    Commented Feb 13, 2020 at 13:57
  • @Jakob. Thanks for that, I am not too great at SQL to write the inner join expression. Would I be able to have a hand with it? Thanks again!
    – LeadStar
    Commented Feb 17, 2020 at 6:29
  • @Jakob sorry I spoke too soon! Thank you so much for your help! I now just have to wrangle with the contouring addin. Thank you again
    – LeadStar
    Commented Feb 17, 2020 at 6:40

1 Answer 1

1

You can probably do it your way, but why not be free as a bird and use sql in a virtual layer:

select t1.x,t1.y, t1.geometry, t2.year 
from table1 t1 
inner join table2 t2 using (id)

Assuming you have geometry in table1. BTW x is long not lat.

A lot of data stuff in QGIS an be handled with a virtual layer. A lot easier to remember than where a dialog with 10 mouse clicks in it is hidden ...

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.