Nested reports display data for group members and the group members that belong to them. These reports work best for hierarchical data. (Examples)


The code to generate nested reports looks like this:

#indicates the start of nested results

{|NESTED|}

  <table class='data'>

    <thead>

      <tr>

        <th>Year</th>

        <th>Month</th>

        <th>Count</th>

      </tr>

    </thead>

    <tbody>

  #start by looping our highest-level group, in this case year (sorted by order num)

  {|LOOP|NESTED.YEAR(SORT=ORDER_NUM)}

    <tr>

      #display the name of our year

      <th>{YEAR.NAME}</th>

      <td></td>

      #display a count of datapoints for this year

      <td>{COUNT(YEAR,YEAR)}</td>

    </tr>

    #now, within this year's loop, loop its months

    {|LOOP|YEAR.MONTH_OF_YEAR(SORT=ORDER_NUM)}

      <tr>

        <th></th>

        #display the name of the month

        <td>{MONTH_OF_YEAR.NAME}</td>

        #display a count of datapoints for this month within this year

        <td>{COUNT(MONTH_OF_YEAR)}</td>

      </tr>

    #end the month loop

    {/|LOOP|}

  #end the year loop

  {/|LOOP|}

    </tbody>

  </table>

#end the nested result

{/|NESTED|}



You may also display datatypes in NESTED reports:

{|NESTED|}

  <table>

    {|LOOP|NESTED.REGIONS(SORT=NAME)}

      {|SHOWIF|LOOP.ISFIRST}

        <thead>

          <tr>

            <th>Name</th>

            <th>Count</th>

            <th>Avg Score</th>

          </tr>

        </thead>

        <tbody>

      {/SHOWIF|}

      <tr>

        <th>{REGIONS.NAME}</th>

        <td>{COUNT(REGIONS,REGIONS)}</td>

        <td>{AVG(REGIONS.SCORE,REGIONS).NUMBERFORMAT(2)}</td>

      </tr>

      {|LOOP|REGIONS.DISTRICTS(SORT=NAME,LIMIT=1|1)}  

        <tr>

          <th>&nbsp;&nbsp;&nbsp;&nbsp;{DISTRICTS.NAME}</th>

          <td>{COUNT(DISTRICTS,DISTRICTS)}</td>

          <td>{AVG(DISTRICTS.SCORE,DISTRICTS).NUMBERFORMAT(2)}</td>

        </tr>

        #loop datapoints for this district in this region

        {|LOOP|DISTRICTS.DATAPOINTS(SORT=TRENDING_TIMESTAMP)}  

          <tr>

            <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{DATAPOINTS.ID}

            </th>

            <td>1</td>

            <td>{DATAPOINTS.SCORE.NUMBERFORMAT(2)}</td>

          </tr>

        {/|LOOP|}

      {/|LOOP|}

    {/|LOOP|}

    </tbody>

  </table>

{/|NESTED|}