Convert InfluxQL to flux influxDB API flux query for version 1.8

SELECT COUNT(${column}) AS total
      FROM ${measurement}    
      WHERE time > '${timeFrom}'
      AND time <= '${timeTo}' 
          ? `AND ( locationLevel2 = '${locationId}'
      OR locationLevel3 = '${locationId}'
      OR locationLevel4 = '${locationId}'
      OR locationLevel5 = '${locationId}'
      OR officeLocation = '${locationId}')`
          : ``
    GROUP BY time(30d), timeLabel, eventLocationType ORDER BY time DESC

I want to convert this to flux query which will support in influxDB version 1.8. instead of time(30d), want to group by each month.

Hi @robin,
Welcome to the community:

from(bucket: "plantbuddy")
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r._measurement == "sensor_data")
    |> filter(fn: (r) => r. locationId == "" or filter(fn: (r) => r. locationId2 == "")
    |> aggregateWindow(every: 1mo , fn: count, createEmpty : false)

Hopefully, that starts you off! I would also check out this blog: TL;DR InfluxDB Tech Tips: Converting InfluxQL Queries to Flux Queries | InfluxData