monthname(addmonths(Date#(Fecha,'MMM YYYY'),+MesesDep)) as FinalDate
drop Table Tabla;
RENAME Table t to Tabla;
This created a table with the amounts I need to add to each month (DepMensual) and the start and finishing dates of the calendar, that would be: StartDate and FinalDate.
I know I can autogenerate a calendar with this:
$(vMindate)+iterno()-1 as tempdate,
date($(vMindate)+iterno()-1) as Date,
Monthname($(vMindate)+iterno()-1) as MonthYear
autogenerate 1 while $(vMindate)+iterno()-1<=$(vMaxdate);
But I am stock thinking how to create a loop where my variables for Mxdate and Mindate change for each rowno() and IDFactura inside my table: "Tabla". I am thinking maybe a for loop would do the job, but I cannot see how to put it together.
I am expecting to get a single table with the concatenated auto generated calendars from each row in the original "Tabla". So I should get a table with two columns, IDFactura and Month, with 240 rows (5 original rows times 48 for each row). I am working on the for loop, and so far I have this, but it gives me an error:
FOR i = 0 to NoOfRows('Tabla')
let vStartDate= peek('StartDate',i,'Tabla');
let vEndDate= peek('EndDate',i,'Tabla');
let vNomCalendar= peek('DepNum',i,'Tabla');
let vIDFactura= peek('IDFactura',i,'Tabla');
$(vIDFactura) as IDDep,
Monthname($(vStartDate),+iterno()-1) as MonthYear
autogenerate 1 while $(vStartDate)+iterno()-1<=$(vEndDate);
The error is that I am missing a ")", but I dont seem to see where is missing.