I tried out some code to get the "running total" and "subtotal" ,but that did yield successful result.
When the code is given:
var salesPeople =
new SalesPerson[]
{
new SalesPerson{Name="Ricky", RegionCode="R001",SalesAmount=100,
SalesDate=Convert.ToDateTime("01/Jan/2009")},
new SalesPerson{Name="Mark", RegionCode="R001",SalesAmount=200,
SalesDate=Convert.ToDateTime("02/Jan/2009")},
new SalesPerson{Name="Jon", RegionCode="R001",SalesAmount=400,
SalesDate=Convert.ToDateTime("10/Jan/2009")},
new SalesPerson{Name="Ricky", RegionCode="R001",SalesAmount=100,
SalesDate=Convert.ToDateTime("05/Jan/2009")},
new SalesPerson{Name="Mark", RegionCode="R001",SalesAmount=200,
SalesDate=Convert.ToDateTime("07/Jan/2009")},
new SalesPerson{Name="Jon", RegionCode="R001",SalesAmount=250,
SalesDate=Convert.ToDateTime("11/Jan/2009")},
new SalesPerson{Name="Ricky", RegionCode="R002",SalesAmount=50,
SalesDate=Convert.ToDateTime("01/feb/2009")},
new SalesPerson{Name="Mark", RegionCode="R002",SalesAmount=120,
SalesDate=Convert.ToDateTime("02/feb/2009")},
new SalesPerson{Name="Peter", RegionCode="R002",SalesAmount=30,
SalesDate=Convert.ToDateTime("10/feb/2009")},
new SalesPerson{Name="Ricky", RegionCode="R002",SalesAmount=400,
SalesDate=Convert.ToDateTime("05/feb/2009")},
new SalesPerson{Name="Mark", RegionCode="R002",SalesAmount=70,
SalesDate=Convert.ToDateTime("07/feb/2009")},
new SalesPerson{Name="Peter", RegionCode="R002",SalesAmount=60,
SalesDate=Convert.ToDateTime("11/feb/2009")}
};
How can i find the Total,SubTotal,RunningTotal similiar to the following one.
(1) Running Total Based on Region and Month
Sales History
-------------------------------------------------------------
Region Code Name MonthyRunningTotal SalesDate
(By Month)
-------------------------------------------------------------
R001 Ricky 100 01/Jan/2009
R001 Ricky 200 05/Jan/2009
R002 Ricky 50 01/feb/2009
R002 Ricky 450 05/feb/2009
R001 Mark 200 02/Jan/2009
R001 Mark 400 07/Jan/2009
R002 Mark 120 02/feb/2009
R002 Mark 190 07/feb/2009
R001 Jon 400 10/Jan/2009
R001 Jon 650 11/Jan/2009
R002 Peter 30 10/feb/2009
R002 Peter 90 11/feb/2009
and
(2) Total and Subtotal based on Region and Month
Sales History (Based on Region and Month)
-------------------------------------------------------------
Region Code Name MonthyRunningTotal SalesDate
(By Month)
-------------------------------------------------------------
R001 Ricky 100 01/Jan/2009
R001 Ricky 100 05/Jan/2009
Total ----
200
----
R002 Ricky 50 01/feb/2009
R002 Ricky 400 05/feb/2009
Total ----
450
----
R001 Mark 200 02/Jan/2009
R001 Mark 200 07/Jan/2009
Total -----
400
-----
R002 Mark 120 02/feb/2009
R002 Mark 70 07/feb/2009
Total ----
190
----
R001 Jon 400 10/Jan/2009
R001 Jon 250 11/Jan/2009
----
650
----
R002 Peter 30 10/feb/2009
R002 Peter 60 11/feb/2009
-----
90
-----