So 600 for stock using all the data would be
ID = 1, max datetime =2012/06/30 stock=300
ID = 2, max datetime =2012/08/01 stock=300
Whilst selecting January would be
ID = 1, max datetime =2012/01/16 stock=600
ID = 1, max datetime =2012/01/01 stock=250
The trouble is getting the latest value for each ID before summing them.
Does that make more sense?
Now it makes sense. This is one of my favourite topics in QlikView - FirstSortedValue() function. I have made a video series on this one. Please check when you get some time.
Here is what you need....
=Sum(Aggr( FirstSortedValue(Stock, -Datetime), ID))