Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

For loops, start/end dates and keytables

Hi everyone,

I have the foloowing table (simplified of course):

CodeFROM_dateTO_dateManager
10001 - 01 - 201603 - 01 - 2016Hank
10101 - 01 - 201605 - 01 - 2016Edward

Now what i want to make is the following table

DAY-CODE-KEYManager
01-01-2016-100Hank
02-01-2016-100Hank
03-01-2016-100Hank
01-01-2016-101Edward
02-01-2016-101Edward
03-01-2016-101Edward
04-01-2016-101Edward
05-01-2016-101Edward

So basically i want to load each row in the top-table and then use a FOR-loop to create rows in a new table.

I was thinking to loop through the lines, then set two vars with peek (from and to), and then loop from 'from' to 'to' and create the lines in table 2.

Am I thinking in the wrong direction? Cause I can't seem to nest two for statements....

Kind regards,

Herb

1 Solution

Accepted Solutions
sunny_talwar

Another options:

Intervals:

LOAD Date,

  Code,

  Date & '-' & Code as [DAY-CODE-KEY],

  Manager;

LOAD Date(FROM_Date + IterNo() - 1) as Date,

  Code,

  Manager

While FROM_Date + IterNo() - 1 <= TO_date;

Load * Inline [

FROM_Date, TO_date, Code, Manager

01-01-2016, 03-01-2016, 100, Hank

01-01-2016, 05-01-2016, 101, Edward

];


Capture.PNG

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Herb,

I think you can use the intervalmatch function. Take a look at this script and see if it can help you along the way.

best regards,

Helena

sunny_talwar

Another options:

Intervals:

LOAD Date,

  Code,

  Date & '-' & Code as [DAY-CODE-KEY],

  Manager;

LOAD Date(FROM_Date + IterNo() - 1) as Date,

  Code,

  Manager

While FROM_Date + IterNo() - 1 <= TO_date;

Load * Inline [

FROM_Date, TO_date, Code, Manager

01-01-2016, 03-01-2016, 100, Hank

01-01-2016, 05-01-2016, 101, Edward

];


Capture.PNG

Anonymous
Not applicable
Author

Thanks, this time I chose the iterative solution provided by Sunny.

Thanks for the example of proper use of an interval function.

Anonymous
Not applicable
Author

Thanks, works exactly as needed.