This is a migrated thread and some comments may be shown as answers.

How to filter data when calculate the average?

0 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ABC
Top achievements
Rank 1
ABC asked on 15 Apr 2013, 06:50 PM
I use this:
.DataSource(dataSource => dataSource
.Ajax()
.Aggregates(aggregates =>
{
aggregates.Add(p => p.UnitsInStock).Min().Max().Count();
aggregates.Add(p => p.UnitsOnOrder).Average();
aggregates.Add(p => p.ProductName).Count();
aggregates.Add(p => p.UnitPrice).Sum();
})
.Group(groups => groups.Add(p => p.UnitsInStock))
.Read(read => read.Action("Aggregates_Read", "Grid"))

Now I want to calculate the sum  of UnitPrice without those price which <0 and background is not transparent(without color);I write the codes down,but it is wrong.
.DataSource(dataSource => dataSource
.Ajax()
.Aggregates(aggregates =>
{
aggregates.Add(p => p.UnitsInStock).Min().Max().Count();
aggregates.Add(p => p.UnitsOnOrder).Average();
aggregates.Add(p => p.ProductName).Count();
aggregates.Add(p => p.UnitPrice).Sum(p.UnitPrice>0&&p.background==transparent);
})
.Group(groups => groups.Add(p => p.UnitsInStock))
.Read(read => read.Action("Aggregates_Read", "Grid"))

No answers yet. Maybe you can help?

Tags
Grid
Asked by
ABC
Top achievements
Rank 1
Share this question
or