title: Aggregate child table values in Birt
body: <p>I have this Birt report that I inherited from another developer, consisting of a child table inside a master table. For each row in the master table, the child table lists items belonging to the current master row item.</p>
  
  <p>The two tables are fed from different data sets, the child table dataset taking a parameter indicating the master item whose child items to fetch.</p>
  
  <p>Now, what I need to do is add a SUM aggregate to the bottom of the master table, showing the total (for all master items) of a certain field in the child table.</p>
  
  <p>Consider, for example, the following data:</p>
  
  <pre><code>MasterItem1
              ChildItem1 SomeValue
              ChildItem2 SomeValue
              ChildItem3 SomeValue
  MasterItem2
              ChildItem1 SomeValue
              ChildItem2 SomeValue
              ChildItem3 SomeValue
  --------------------------------
                         Total
  </code></pre>
  
  <p>(Why wasn't this done with grouping instead? Short answer: There are in fact <em>two</em> child tables to each master row, containing different numers and types of fields, so the previous developer probably didn't figure out a way to accomplish this with grouping.)</p>
  
  <p>At first I thought I could simply add another child table inside the Total field, with an aggregate summing up the values from the child dataset. That didn't work, however, since the child dataset requires a parameter indicating the master item whose children to fetch, so there is no way to get ALL values from the child dataset at once.</p>
  
  <p>I'm thinking there might be a way to create an expression that references the SomeValue fields in the child table directly, instead of going through the child data set.</p>
  
  <p>Any suggestions are <em>greatly</em> appreciated.</p>