FIRST RECORD([Technicians]) While(Not(End selection([Technicians]))) QUERY([Interventions];[Interventions]Technician_Initials=[Technicians]ID) // we have the list of interventions for the technician in memory. QUERY SELECTION([Interventions];[Interventions]Intervention_Date>=$YearStart;*) QUERY SELECTION([Interventions];&;[Interventions]Intervention_Date<=$YearEnd)
To avoid setting the size of arrays before performing the loop and assigning a value to the $Index variable during the process (which lets us discover the Selected record number function), you can use the APPEND TO ARRAY command.