//loop through Range1 for i= peek('r_start') to peek('r_end')
NewData:
LOAD ID as n_ID, '$(i)' as n_Day, Value as n_Value
Resident Data
where d_start <= $(i) and d_end >= $(i);
next i;
I'm not sure what logic you are using when there are 2 possible values on a single day (ID1 has -6*1 and 1*7), so you may need to add code to allow for this.