Page 1 of 1

Summarizing data from a nested databands nested databand.

Posted: Tue Feb 16, 2016 1:38 pm
by GeorgeCrane
So i have 3 tiers of databands like this
- Grandparent
-- Parent (master is Grandparent, nested databand)
--- Child (master is Parent, nested databands nested databand)
The data is also related in a similar way, parent has a id relationship to grandparent, and child has a id relationship to parent.

In the Child data there is values I want to summarize, first in the parent, then in the grandparent.
An example
- Grandparent, Grandchild sum = 10 (1+2+3+4)
-- Parent, Child value sum = 3 (1+2)
--- Child, value = 1
--- Child, value = 2
-- Parent, Child value sum = 7 (3+4)
--- Child, value = 3
--- Child, value = 4
(I've attached a project and data as a proper example.)

I get the right numbers in parent by using {Sum(Child, childData.value)}. But if I put the same formula in the grandparent databand I do not get the expected result, I get the result one of the parents had at some time.
How do I get the grandparent databand to summarize correctly the values from it's grandchildren?

Re: Summarizing data from a nested databands nested databand

Posted: Tue Feb 16, 2016 8:29 pm
by Jan
Hello, George!

You can calculate totals by data source also. For example, you can use child data source in this case. Try to use:

Code: Select all

{Totals.Sum(child, child.childValueToSum)}
Let me know if you need any help.

Thank you.

Re: Summarizing data from a nested databands nested databand

Posted: Wed Feb 17, 2016 9:12 am
by GeorgeCrane
Hi Jan!

Thank you for your response, it works great if there is only one grandparent.

My usecase requires that I support multiple grandparents, as in here;

- Grandparent, Grandchild sum = 10 (1+2+3+4)
-- Parent, Child value sum = 3 (1+2)
--- Child, value = 1
--- Child, value = 2
-- Parent, Child value sum = 7 (3+4)
--- Child, value = 3
--- Child, value = 4
- Grandparent, Grandchild sum = 26 (5+6+7+8)
-- Parent, Child value sum = 11 (5+6)
--- Child, value = 5
--- Child, value = 6
-- Parent, Child value sum = 15 (7+8)
--- Child, value = 7
--- Child, value = 8

Any suggestions are appreciated.

Re: Summarizing data from a nested databands nested databand

Posted: Wed Feb 17, 2016 1:30 pm
by HighAley
Hello.

In this case you better to use this expression:
Grandchild Sum: {Sum(DataBand2:DataBand3,child.childValueToSum)}

Thank you.

Re: Summarizing data from a nested databands nested databand

Posted: Wed Feb 17, 2016 2:10 pm
by GeorgeCrane
Holy... that worked!
Thank you Aley!

Re: Summarizing data from a nested databands nested databand

Posted: Wed Feb 17, 2016 3:00 pm
by HighAley
Hello.

We are always glad to help you.
Let us know if you need our help.

Thank you.

Re: Summarizing data from a nested databands nested databand

Posted: Thu Feb 18, 2016 8:44 am
by GeorgeCrane
Actually, I have a quick follow up;

What if I have another tier, one of great-grandparent that wants to sum the value of the great-grandchildren?
See attached file.

Example Structure (admittedly this is getting a bit silly)

-Great-Grandparent, Great-grandchild sum = 36 ( 1+2+3+4 + 5+6+7+8)
-- Grandparent, Grandchild sum = 10 (1+2+3+4)
--- Parent, Child value sum = 3 (1+2)
---- Child, value = 1
---- Child, value = 2
--- Parent, Child value sum = 7 (3+4)
---- Child, value = 3
---- Child, value = 4
-- Grandparent, Grandchild sum = 26 (5+6+7+8)
--- Parent, Child value sum = 11 (5+6)
---- Child, value = 5
---- Child, value = 6
--- Parent, Child value sum = 15 (7+8)
---- Child, value = 7
---- Child, value = 8
-Great-Grandparent, Great-grandchild sum = 100 (9+10+11+12+13+14+15+16)
-- Grandparent, Grandchild sum = 10 (9+10+11+12)
--- Parent, Child value sum = 19 (9+10)
---- Child, value = 9
---- Child, value = 10
--- Parent, Child value sum = 23 (11+12)
---- Child, value = 11
---- Child, value = 12
-- Grandparent, Grandchild sum = 58 (13+14+15+16)
--- Parent, Child value sum = 27 (13+14)
---- Child, value = 13
---- Child, value = 14
--- Parent, Child value sum = 31 (15+16)
---- Child, value = 15
---- Child, value = 16

Re: Summarizing data from a nested databands nested databand

Posted: Fri Feb 19, 2016 11:50 pm
by Ivan
Hello,

We found some problem in our code, so we need some additional time for check the issue.

Thank you.

Re: Summarizing data from a nested databands nested databand

Posted: Wed Feb 24, 2016 7:59 am
by HighAley
Hello.

The expression should be next:

Code: Select all

Great-grandchild sum: {Sum(DataBand1:DataBand3,child.childValueToSum)}
But we have found a bug when on some data the sum was calculated wrong.
In your report you see the bug in the Great-grandchild sum.
We have made an improvement of the issue.
The patch will be available in our next prerelease build.

Thank you.