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

hierarchical data, subreport value aggregation

4 Answers 219 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ivo
Top achievements
Rank 1
Ivo asked on 22 Jan 2013, 10:18 AM
Hi all,
I have a hierarchical data structure and I am using a sub report with object data source to recursively iterate over it. 
In all the leaf nodes I have a value that I would like to aggregate in a bottom up manner and display the running aggregate at each level.  Aggregating the values outside of the report is not an option at the moment.

Basically, it boils down to passing values from all the subreports up to the parent report.
I am still new to Telerik so some pointers / techniques/patterns would be highly appreciated 

Report should look like this in the end

(root) 12
    (A1) 3
      (B1) 1      // leaf
      (B2) 2      // leaf
   (A2)  9 
     (C1) 6
        (D1) 4
           (E1) 1 // leaf
           (E2) 3 // leaf
         (D2) 2   // leaf
    (C2) 3        // leaf
etc...

Greetings.

4 Answers, 1 is accepted

Sort by
0
Ivo
Top achievements
Rank 1
answered on 23 Jan 2013, 08:46 AM
you can do it by going down the processing items tree but that is kind of ugly and not very maintainable. 
telerik, could you please consider adding some return values especially from subreports. 
0
Stef
Telerik team
answered on 25 Jan 2013, 12:48 PM
Hello Ivo,

It is not very clear where you want to display aggregates- in the sub report, in the main report, what aggregates are displayed, what is the report structure - what is in the main report and what in sub report.
If you want to access some item from a sub report, you can use the subReport item ItemDataBound event and loop through the items of the report to find the needed one.
In addition, if you decide to change the report layout the table/crosstab item is good choice in representing hierarchical data with running total on different levels. For more details check Sales by Product Line per Period online demo and the example installed locally on your machine under C:\Program Files (x86)\Telerik\Reporting Q3 2012\Examples\CSharp\ReportLibrary\Crosstab.

If you need more help with this, please elaborate on your scenario. If possible, send us a runnable sample project or code snippets illustrating your issue.

All the best,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Ivo
Top achievements
Rank 1
answered on 29 Jan 2013, 12:03 PM
Hi Stef,

attaching code is not possible in this thread and i am not sure if i can submit a report ticket with the trial license i am using to evaluate telerik reporting.

anyways.  I have attached a snapshot of my report definition and a simplified version of my data object. The source for the topmost report is a list of objects and the data source for the subreport is the Children property in each these object. The data is a tree like structure that can run up to 4 levels deep. 

I managed to get the aggregate by iterating over the subreport processing items as each successive level gets processed and replacing the value field with the sum of the subreport items value fields. This approach works but changing the sub-report slightly would easily introduce bugs.  I was wondering if there is a better way to do that i.e. declaring a return value for the subreport that could be used directly in the report definition i.e. "=Sum(Subreport.ReturnValue1)". 

Another question that I need help with is how would i go about replacing the recursive subreport with a table/crosstab control?

Thanks.
0
Stef
Telerik team
answered on 01 Feb 2013, 01:28 PM
Hello Ivo,

Just log with the account used to download the trial and you will be able to send us a support ticket with zip file attachments.

Up to your questions. Pulling data from sub report to main report is not a good practice, so rearrange your data to contain the needed information before providing it, instead of using the layout to iterate through the data. If you intend using the suggested table structure in the context of self-referencing data source, notice that the table definition should be created before the data processing begin, in other words it will require evaluating the provided data in order to create the item structure.

I hope this helps.

Regards,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Ivo
Top achievements
Rank 1
Answers by
Ivo
Top achievements
Rank 1
Stef
Telerik team
Share this question
or