I have daily temperature data for several cities from January to December. I'd like to calculate the average temperature per month for each city in a new column.
I have a column "city"
, "day"
, "month"
and "temperature"
.
I've tried to do the following in the field calculator, but the result gives the same average temperature for all cities.
case
when "CITY" = 'LONDON' then mean("TEMP", group_by:="MONTH")
else ''
end
||
case
when "CITY" = 'PARIS' then mean("TEMP", group_by:="MONTH")
else ''
end
Also, I imagine it's possible to do this without having to call the name of each city. This would be great, as there are hundreds of them. How can I modify this code to get the desired result?
I am using QGIS 3.30.1