# Reports - creating nested tables for Table Group

**URL:** <https://forum.inductiveautomation.com/t/reports-creating-nested-tables-for-table-group/39637>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [October 13, 2020, 2:10pm UTC](https://forum.inductiveautomation.com/t/reports-creating-nested-tables-for-table-group/39637 "2020-10-13T14:10:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigl](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/craigl/32/5010_2.png) [@craigl](https://forum.inductiveautomation.com/u/craigl)\
**Post date:** [October 13, 2020, 2:10pm UTC](https://forum.inductiveautomation.com/t/reports-creating-nested-tables-for-table-group/39637/1 "2020-10-13T14:10:55Z")

</div>

I’m new to reporting and I’m trying to create a table that has sub tables (table group). The general format desired is something like:

Cut area:  
Cut Machine 1 output details blah blah blah  
Cut Machine 2 output details blah blah blah

Total of cut machines output machine output blah blah blah

Print area:  
Print Machine 1 output details blah blah blah  
Print Machine 2 output details blah blah blah

Total of print machines output blah blah blah

Etc.

So, I think what I need to do is create a dataset with sub datasets to feed the report, but the sub datasets aren’t working. I’m sure I’m missing something obvious in the second to the last line.

```auto
      areaQuery = "ProductionModel/GetAreasDashboard"
      lineQuery = "ProductionModel/GetLinesByArea"

       parameters = {"AnalysisName":"Analysis"}

       # Get a list of the areas in this plant         
      areas = system.db.runNamedQuery(areaQuery, parameters)
      areaCount = areas.getRowCount()
      areaData = dict()
      lineData = []
      for areaIndex in range(areaCount):
         logger.info("Area %s" % areas.getValueAt(areaIndex, 'EquipmentName'))
         areaName = areas.getValueAt(areaIndex, 'EquipmentName')
         parameters = {"AnalysisName":"Analysis","Area":areas.getValueAt(areaIndex, EquipmentName')}
         # Get a list of the lines for the selected area         
         lines = system.db.runNamedQuery(lineQuery, parameters)
         linesCount = lines.getRowCount()
         headers = ["Area", "Line", "LineData"]
         for lineRow in range(linesCount):
            linePath = lines.getValueAt(lineRow, 'EquipmentPath')
            lineName = lines.getValueAt(lineRow, 'EquipmentName')
            params = {"EquipmentPath":linePath}
             # given line and area, get OEE and production for the specified period
             lineResults = system.mes.analysis.executeAnalysis(data['StartDate'], data['EndDate'], "Production Report", params)
             lineDS = lineResults.getDataset()
             lineData.append([areaName, lineName, lineDS])
                                                
     data['dailyDataByArea'] = system.dataset.toDataSet(headers, lineData);

```

The data fed to the report ends up looking like:

```auto

<dailyDataByArea>
   <row-0>
      <Area>Sheet Area</Area>
      <Line>7101</Line>
      <LineData>Dataset [24R x 20C]</LineData>
   </row-0>

   <row-1>
      <Area>Sheet Area</Area>
      <Line>7102</Line>
      <LineData>Dataset [24R x 20C]</LineData>
   </row-1>

   <row-7>
      <Area>Cut Area</Area>
      <Line>7301</Line>
      <LineData>Dataset [24R x 20C]</LineData>
   </row-7>

   <row-8>
      <Area>Cut Area</Area>
      <Line>7302</Line>
      <LineData>Dataset [24R x 20C]</LineData>
   </row-8>

```

Etc.

Any help greatly appreciated.

Craig L.

---

<div class="post-metadata">

**Author:** ![craigl](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/craigl/32/5010_2.png) [@craigl](https://forum.inductiveautomation.com/u/craigl)\
**Post date:** [October 13, 2020, 2:25pm UTC](https://forum.inductiveautomation.com/t/reports-creating-nested-tables-for-table-group/39637/2 "2020-10-13T14:25:26Z")

</div>

Wow, really sorry about the formatting nightmare that happened there.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 13, 2020, 5:07pm UTC](https://forum.inductiveautomation.com/t/reports-creating-nested-tables-for-table-group/39637/3 "2020-10-13T17:07:10Z")

</div>

> [@craigl](#):
>
> sorry about the formatting nightmare

Edit your post. Select (highlight) all of the code. Click the "code" button that looks like this: \</\>. Do the same in the future for any plain text, like log files and configuration files or XML or JSON.

---

<div class="post-metadata">

**Author:** ![craigl](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/craigl/32/5010_2.png) [@craigl](https://forum.inductiveautomation.com/u/craigl)\
**Post date:** [October 14, 2020, 2:17pm UTC](https://forum.inductiveautomation.com/t/reports-creating-nested-tables-for-table-group/39637/4 "2020-10-14T14:17:07Z")

</div>

Thanks for the tip.

I’m going a different route with the report, so never mind the question. If anyone with permissions wants to delete this topic, go ahead.
