Grafana and sums of multiple rows

Hi,
It seems as it should be pretty straightforward but likely I’m missing some part.
I’m collecting some power data in PDUs (but it can be anything) every 30 seconds.

time rack_tag power_watt
1504696559000000000 15 1015
1504696559000000000 16 1016
1504696559000000000 17 1017

1504696589000000000 15 2015
1504696589000000000 16 2016
1504696589000000000 17 2017

Now I want to graph a sum of power usage in all racks with something like:
SELECT sum(“power_watt”) FROM “measurement” WHERE AND $timeFilter GROUP BY time(30s) fill(previous)

It works pretty fine, but only if there is not time drift while entering the data. If for example the data is being entered a milionth of second earlier - my sum graph has “mountains” on it because it sums up two batches in one interval, and zero in another.

Question - is there a way to do this smarter?
Could I somehow put in a batch tag so that influx can group on them? Still sounds a bit odd, but couldn’t find any exact solution for that.

You can play with average or median on these number but it won’t be the accurate value you need. I would suggest look at the time precision when these values are being inserted into the database. Or you can introduce custom timestamps while inserting the data so you don’t run into this scenario.