Drawing a graph with grouped fields

I am new to flux so please forgive me if the question seems silly.
I had a tag called bssid and a value field called rssi. This produced a graph like this.

This looks like spaghetti but its actually correct and what I need however, I started to run into cardinality issues so, I changed my bssid from a tag to a field. Now I have a bssid and an rssi field. Using a Pivot I can create a table with all the data in it which is great but, I also need to split up the data so that is can produce the same graph as before

from(bucket: "sensor")
  |> range(start: -2m)
  |> filter(fn: (r) => r["_measurement"] == "ap_scan" and  r["_field"] =~ /bssid|rssi/)
  |> pivot(columnKey: ["_field"] , rowKey: ["_time"] , valueColumn: "_value")
  |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false, column: "rssi")
  |> yield(name: "mean")
  1. Should I do it once the table is assembled? how?
  2. Should I use a totally different query? how
    any pointers in the right direction would be appreciated