What I have is a LineItem object and a collection called LineItems that holds LineItem objects. My LineItem objects have a property called ItemDate (DateTime data type) and another property called ItemAmount (decimal data type) and another property called ItemCategory (integer data type).
What I am trying to do is write a function in my collection object that will return the integer category in whichever category has the highest sum(ItemAmount) of that category. For example, if I had this:
Object 1:
ItemAmount=50.00
ItemCategory=1
Object 2:
ItemAmount=25
ItemCategory=1
Object 3:
ItemAmount=535.00
ItemCategory=2
OK so in this example, the function should return 2 since ItemCategory 2 had a bigger ItemAmount (535) than ItemCategory 1 (50+25 = 75).
This I know how to do. What makes it harder though is I need it to be able to do this over time, meaning, if an amount has a large amount, like 535, but some other objects have smaller amounts, but there are more of them to closer dates, then it needs to be techically "larger" than the other amount. It is almost like the amount needs to take into account frequency too. $10 amount occuring everyday needs to be "larger" than $500 occuring once a year, even if the $500 is larger than $10 every day. It is almost like I need to look at a month of data through a year's magnifing glass.
I hope this question makes sense.