Help migrating from InfluxQL to Flux


I’m putting my hands onto Flux query language, while quite used to InfluxQL syntax, and cant’ find a way to translate the following query from InfluxQL to Flux:

SELECT last(“FIELD”)-first(“FIELD”) FROM “measurement” WHERE “some time filter”

Or another similar request:

SELECT last(“FIELD”)-first(“FIELD”) + last(“FIELD2”)-first(“FIELD2”) FROM “measurement” WHERE “some time filter”

Target is (obviously) to get increase in said field(s) value(s) during selected period.

I took a look at flux first() and last() functions, but cannot sort out how to use both of them for calculation. Is it possible?

I am querying from Grafana and InfluxQL works fine for now, but I need to do the same calculation with fields coming from different measurements, which is not possible with InfluxQL.

Thanks in advance for your help!