More downsampling woes

I need to do something, very similar to this:
https://stackoverflow.com/questions/36209516/how-do-i-group-by-count-of-a-field-in-influxdb with Flux rather than 1.x series. My (clearly wrong!) pseudo code is:

data =
    from(bucket: "probe_box")
        |> range(start: -duration(v: int(v: task.every) * 2))
        |> filter(fn: (r) => r[ "mac_address"])
        |> count(mac_address)

data
    // Stores the aggregated data in a new bucket
    |> to(bucket: "probe-downsampled", org: "uni")

Do I need to use windowAggregate? I suspect a few other people, apart from the above need to do this too?

TIA Hugh