1

I have two nested loops each one use a different node to get data:

1) <?for-each-group:/DATA/TEST/ROW;./target_test?>  
2) <?for-each:/DATA/TEST2/ROW?>

Looping with the first group for each target_test I generate a page of report and with the second group I fill a table. At this point the report works well if I have just one target_test, but if I have have more target_test the table is filled with all target_test and not only with the one which upper loop is refered. So as result for example i have the page with target_test = data1 that in the table contains also target_test = data2, target_test = data3 etc..

My question is: is possible to check with a condition if target_test in the second loop is equal to target test in the first loop? With this condition I can simply hide rows of the table when condition is not true.

Sharknado
  • 27
  • 1
  • 6

2 Answers2

2

You are telling the code to do this:

For every row in test with a different target_test value, loop over every row in TEST2.

So this is expected behaviour. You do not specify how the outer loop target_test should affect the inner loop.

You probably want something like this:

<?for-each-group:/DATA/TEST/ROW;./target_test?>  
<?for-each:/DATA/TEST2/ROW[target_test=current-group()/target_test]?>
do something
<?end for-each?>
<?end for-each-group?>

If this doesn't help, please provide a reproducible example with a data sample.

Based
  • 950
  • 7
  • 18
1

Easiest way out seems to use variables, in the outerloop, store thed target_test value into a variable (set_variable), and then check that in the second loop.

But it is also possible to filter in the second loop for only the records matching the parent loop. This is possible with and without variables, using the filter (square brackets) .

Ranjith R
  • 1,571
  • 1
  • 11
  • 11
  • Many thanks to your answer! Considering that i'm new in using BI Publisher, could be possible have an example? Because for variables I found only examples with numeric costant values. – Sharknado Jun 13 '19 at 07:36
  • I see the good @Peter Paff has already given a working solution using filter, what I had hinted at. – Ranjith R Jun 13 '19 at 22:26