"You must loop all lower-level iterators before looping the upper-level iterator."
This error may display when you are working with a CROSSTAB or NESTED report type.
Reports of this type are composed of several nested iterators, one for each group you’re breaking out.
For example, in a report crosstabbing YEAR by MONTH_OF_YEAR, there is one iterator of YEAR group members, each of which contains an iterator of MONTH_OF_YEAR group members. It is not possible to skip forward to the next YEAR iterator without looping through the current YEAR’s entire MONTH_OF_YEAR iterator.
Seeing this error message means that, for at least one loop through an outer iterator, one or more inner iterators are not being looped. This may happen if the only inner-iterator looping you’re doing is enclosed in {|SHOWIF|LOOP.ISFIRST}{/|SHOWIF|} or if you’re skipping some inner iterators for the sake of displaying headers.
The example below will fail because the DAY_OF_WEEK iterator is only being looped the first time through the MONTH_OF_YEAR iterator. It can be fixed by looping DAY_OF_WEEK outside of the |SHOWIF| block.
{|CROSSTAB|}<table>
{|LOOP|CROSSTAB.MONTH_OF_YEAR}
{|SHOWIF|LOOP.ISFIRST}
<thead>
<tr>
<th>Name</th>
{|LOOP|MONTH_OF_YEAR.DAY_OF_WEEK(SORT=NAME)}
<th>{DAY_OF_WEEK.NAME}</th>
{/|LOOP|}
<th>{DATATYPES.SHOW_DATATYPE.MONTH_OF_YEAR.GROUP.NAME} Average</th>
<th>{DATATYPES.SHOW_DATATYPE.MONTH_OF_YEAR.GROUP.NAME} Count</th>
</tr>
</thead>
<tbody>
{/|SHOWIF|}
{/|LOOP|}
{/|CROSSTAB|}
The example below will fail because the DATAPOINTS iterator is not being looped when displaying the header row. It can be fixed by adding {|LOOP|MONTH_YEAR.DATAPOINTS(SORT=TRENDING_TIMESTAMP)}{/|LOOP|} to the header’s MONTH_YEAR loop.
{|CROSSTAB|}<table>
{|LOOP|CROSSTAB.DISTRICTS(SORT=NAME)}
{LOOP.ISFIRST?:|VANISH|}
<thead>
<tr class="header-row">
<th rowspan="2">Name</th>
<th>Avg Score</th>
{|LOOP|DISTRICTS.MONTH_YEAR(SORT=ORDER_NUM|DESC,CROSSTAB_FILTER=NO_BLANKS)}
<th class="crosstab-name">{MONTH_YEAR.NAME}</th>
{/|LOOP|}
</tr>
</thead>
<tbody>
{/LOOP.ISFIRST?:|VANISH|}
<tr>
<th>{DISTRICTS.NAME}</th>
<td><span>{AVG(DISTRICTS.SCORE,DISTRICTS).NUMBERFORMAT(2)}</span>
<br/>(<span>{COUNT(DISTRICTS,DISTRICTS)}</span>)
</td>
{|LOOP|DISTRICTS.MONTH_YEAR}
<td><span>{AVG(MONTH_YEAR.SCORE,DISTRICTS,MONTH_YEAR).NUMBERFORMAT(2)}</span>
<ul class="shop-list">
{|LOOP|MONTH_YEAR.DATAPOINTS}<li>{DATAPOINTS.SCORE}</li>{/|LOOP|}
</ul>
</td>
{/|LOOP|}
</tr>
{/|LOOP|}
</tbody>
</table>
{/|CROSSTAB|}