 # Summarizing Values with different time periods (aggregations)

I want to summarize my daily used energy.
Normally I collect values per minute. Sometimes I’m not able to collect the values per minute, but per 10 minutes or hours. In that case these are aggregated values for a larger time period.
The question is how to summarize values with different time periods.
I want to have a graph with totals usage per day.

select sum(value) from your_measurement WHERE \$timeFilter group by time (1d)

that don’t give me the right result

The situation is that I have a table with 2 fields. One for value and one for duration.
So if the table contains:
value duration
480W 60sec
600W 600sec

The first entry will contribute 480x60/3600 = 8Wh to the day total and the second 600x600/3600=100Wh
So I need a formula like value x duration / 3600 group by 1d

I’m looking for the correct syntax to use

looking at the math operators, this should be possible to calculate within the query as you sepcified.

SELECT sum(“watts”*“duration”/3600) FROM “modulo” group by 1d

this is not dry coded, but should basically work.

The thing is that it looks like Sum only may contain 1 field.
I found the problem in that the durations of 1;10 and 60 minutes were based on the average Watt usage within that timeframe, while the duration of a day contained a value on total usage for that day (YouLess). This was the cause I could not find a formula to deal with them all. I now solved it to make a separate daily usage series in my InfluxdB.

Thanks for helping