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

SUM column cell values in a table

3 Answers 2259 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ciccio
Top achievements
Rank 1
ciccio asked on 04 Aug 2011, 10:34 AM
Hello,
a simple question:
i have a sort of dashboard page where are shown  5 tables.
Each table has a datasource , each datasoure is the collection resulting by LINQ statements.

Let say one of this tables haas 2 columns. How i can get the sum of the values of a column and put the result at the fott of that column?

COL1    COL2
a            2
b            3
              5 =====> this is what i'am asking for 

thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Chris Gillies
Top achievements
Rank 1
answered on 04 Aug 2011, 11:30 AM
You add a total row directly from the context menu of the table and use an expression using the Sum aggregate function e.g. = Sum(Fields.Col2)
0
ciccio
Top achievements
Rank 1
answered on 11 Aug 2011, 11:54 AM
Thank for answer.
What if i want to calculate the percentage for each row?
0
Accepted
Steve
Telerik team
answered on 12 Aug 2011, 04:04 PM
Hello Ciccio,

You can use a data scope related function for such scenario e.g. Exec(scope, expression) - executes the specified expression in the given data scope. Used mostly with aggregate expressions as a second parameter; this function allows changing of the data scope in which the expression is evaluated. Scope parameter is the name of the data scope we need to evaluate the expression against. For example the expression:

=Fields.Col2 / Exec(' Report1 ', Sum(Fields.Col2))

used in detail section will return the Col2 amount as percentage from the whole report.

Kind regards,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
General Discussions
Asked by
ciccio
Top achievements
Rank 1
Answers by
Chris Gillies
Top achievements
Rank 1
ciccio
Top achievements
Rank 1
Steve
Telerik team
Share this question
or