# [rrd-users] RPN Question

Simon Hobson linux at thehobsons.co.uk
Tue Apr 17 15:17:22 CEST 2007

```Wesley PA4WDH wrote:

>I have a lot of rrd's with the same DS in it. What i
>want to do is to calculate the sum of all the DS's and
>display that in a "total" graph.
>
>The problem is that those DS's have a lot of unknown
>values in it. What i need is a RPN that does:
>
>if (value_of_ds != unknown)
>return new_value+total_caluclated_so_far
>
>I have tried this:
>total=new_value,UN,total_calucated_so_far,total_calulated_so_far,new_value,+,IF

I would suggest keeping it simple to start with - it's tempting to go
for a long formula that spans 10 lines of code, but it's a nightmare
to debug !

So I would suggest something like (please check the syntax, I might
have got the IF statement wrong) :

i1=v1,UN,0,v1,IF
i2=v2,UN,0,v2,IF
total=i1,i2,+,i3,+, .... in,+

Of course you could start combining stuff, one way being by simple
substitution :

total=v1,UN,0,v1,IF,v2,UN,0,v2,IF,+,v3,UN,0,v3,IF,+  ... in=vn,UN,0,vn,IF,+

Or you could break down your running total as :

t1=v1,UN,0,v1,IF
t2=v2,UN,0,v2,IF,t1,+
t3=v3,UN,0,v3,IF,t2,+

Where v1 .. vn are your data values.

```