# [rrd-users] Question about averaging daily ; but with 5 min. steps

Jean-Yves Avenard jyavenard at gmail.com
Tue Dec 15 13:00:45 CET 2009

```Hi

I got a bit closer to what I wanted to do today ...

2009/12/15 Jean-Yves Avenard <jyavenard at gmail.com>:
> However, if I use 5 minutes average (the same calculation as performed
> by the electric meter) the amount of energy put back in the grid is:
> (1000 - 500) * 10 / 60 * 24 / 1000 = 2kWh per day.
> \
>   CDEF:cexport=csolar,UN,0,csolar,IF,ctotal,-,0,MAX \
>   CDEF:cexport30=csolar30,UN,0,csolar30,IF,ctotal30,-,0,MAX \
>   CDEF:cexporttot=solar30,UN,0,solar30,IF,total30w,UN,0,total30w,IF,-,0,MAX,\$duration,*
[snip]
> So back to my original question:
> How do I graph with RRD ; a daily average made on a 5 minutes average
> of a substraction of 2 values of two different RRD input.
> And is this even possible currently ?

I calculated as follow:
CDEF:cexport30b=COUNT,\$res,300,/,%,0,EQ,cexport30,\$res,TRENDNAN,UNKN,IF \

Basically, I look at the position of the value in the dataset ; if it
doesn't fall on a multiple of 5 minutes, I push UNKNOWN, if not ,
using TRENDNAN, I calculate the average at this point of the last 5
minute and push it on the stack.

Now, I can calculate the maximum and the minimum properly...
Unfortunately, I still can't plot properly because rather than putting
UNKNOWN, I should be putting nth-time the average just calculated.
So if calculating an hourly average, I should be duplicating 12 times
the 5 minutes average.

Unfortunately, the RPN stuff doesn't give me that much leeway...

Does anyone have any other ideas on how to achieve what I've been talking about?

Thanks
Jean-Yves

```