In my stock i have same TWO quanties which i purchased at different rates follows:
srno Item qty product_rate value
1. A 10 1 10
2. A 6 1.5 9
Now in my stock have 5qty from my 1st purchase (with purchase rate as rs.1)
and 2nd purchase i have 6qty .
now as per me weighted avg: is =
total qty=5+6=11 and value=5+9=14
and product rate changes to rs.1.27
Within charts you could use something like this:
rangeavg(above(sum(value), 0, rowno(total)))
and within the script you could use peek() and previous() to access previous records: Peek() or Previous() ?