Trying to Trend the TopN Pedestals

Hello, I’m new to influxdb and learned from the Influx DB University. I have my pedestal data going into influxdb. I use curl and the 300 pedestals send data in like this:
p=229 a=46,w=0
p=230 a=45,w=8
p=231 a=44,w=13
For example: p=229 is the IoT pedestal sending the measurements. a= the kW and w = gallons of water. That’s it. Pretty simple? Well, I’m struggling. I have basic reports in the dashboard but, figuring out how to trend the Top 10 pedestals for kW use for the time frame selected is proving to be difficult for a person with novice flux skills. Can someone point me in the right direction? Thank you.

Hello @Michael_Patterson,
Welcome!
First I want to apologize for the delay, the team was onsite last week preparing for InfluxDays (it’s free if you want to join :slight_smile: https://www.influxdays.com/ )

To display the top 10 pedastals I would do a Flux query that looks like this:
I’m assuming that pedastals is a tag?
If it’s a tag:

from(bucket: "myBucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "myMeasurement")
  |> filter(fn: (r) => r["_field"] == "w")
  |> max() 
  |> group() 
  |> top(n: 10)  
  |> yield(name: "top 10 assuming pedastals are a tag")

Assuming they’re a field

from(bucket: "myBucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "myMeasurement")
  |> filter(fn: (r) => r["_field"] == "w" or r["_field"] == "p")
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")  
  |> group(columns: ["p"]) 
  |> max(column: "w") 
  |> group() 
  |> top(n: 10, columns: ["w"])  
  |> yield(name: "top 10 assuming pedastals are a field")

Let me know if that helps!

Hey Anais, Thank you for responding. I got “No Results”.
My raw data (see image):


I watched your videos in the University which helped a lot. I think I just need to watch several dozen examples and maybe it will start to sink in. I’ll check out the influx days to see if they will help me.

Hello,
@Michael_Patterson,
Sorry for the delay. This slipped through the cracks.
Can you try the query again but place the yeild() after each line after the filter function and tell me which line it breaks at/shows no results?
Thank you.

Hey Anais, I have 2 houses in Cape Coral, FL and both were hit hard by hurricane. I’ll get back to this in a few weeks.