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

How to summarize all item detail totals at the foot of a report?

3 Answers 436 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 13 Feb 2012, 01:24 PM
I currently have a standard report that is working well and looks something like the following:

-----------------------------
Product: Foo
-----------------------------
Date      Itmes Sold    Total
Feb 01    5             14.95
Feb 03    2             5.98
Feb 04    10            29.90
-----------------------------
Total     17            50.83 [1]
-----------------------------

-----------------------------
Product: Bar
-----------------------------
Date      Itmes Sold    Total
Feb 01    7             34.94
Feb 03    1             4.99
-----------------------------
Total     8             39.92 [1]
-----------------------------

//...
more products
//....

-----------------------------
Report
Totals    26            90.75
-----------------------------

I've been asked to include a summary at the bottom of the report.  The summary will list the totals for each product (the information marked [1] above) similar to the following:


-----------------------------
Summary
-----------------------------
Foos      17            50.83
Bars       8            39.92
-----------------------------
Total     26            90.75
-----------------------------


As there is only one item detail per report, can this be done?  How would I create the summary?  Do I need to create a sub report?

Any help would be appreciated.


3 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 15 Feb 2012, 05:43 PM
Hello David,

It depends on the layout of the report. If the data-source is bound to the report directly (you do not use table or similar component), then in the report footer you can simply use aggregate functions =Sum(Fields.ItemsSold). If you use table you can add totals to the table from its context menu.

Kind regards,
Elian
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
David
Top achievements
Rank 1
answered on 20 Feb 2012, 11:51 AM
Thanks Elian. I already use the aggregate functions (=Sum(Fields.ItemsSold)) in order to generate the totals for each product.  

I'm not sure if I was clear, but that part of the report is all working correctly. For each product, I have a row for each date containing the items sold for that date and a footer row displaying the totals for that product.    

What I'm now trying to achieve is to have a summary at the bottom of the report that lists each product and the total sold across all dates.  Basically the totals data from the footer of the row item.  The data a SQL 'GROUP BY query would produce.

So I don't want one row of totals at the bottom of the report, such as

-----------------------------
Report
Totals    26            90.75
----------------------------- 

Which we already have, I want a summary of the report data with the totals for each product, such as

-----------------------------
Summary
-----------------------------
Foos      17            50.83
Bars       8            39.92
-----------------------------
Total     26            90.75
----------------------------- 


Is this possible or do I need a sub report?

The data is currently bound to a DataSet.
0
Elian
Telerik team
answered on 20 Feb 2012, 05:20 PM
Hello David,

The easiest way to do this is to aggregate the data from the data-source and bind it to a table in the report footer. For example your data is in this format:
Name, Cost
...         , ...
...         , ... 
...         , ... 

Normally you would do :
SELECT Name, Cost FROM ... (writing it like a query to be understable)

To get the totals in the report footer your query should be like:
SELECT Name, Sum(Cost) as TotalCost, FROM.... GROUP BY Name

This way you will directly get the aggregated totals. 

Since you are using DataSet, you will have to take care of the grouping manually. 

Regards,
Elian
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Elian
Telerik team
David
Top achievements
Rank 1
Share this question
or