
Creator II
2019-11-05
03:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do While Loops through months
Hi,
I want to generate an inline table which populates with do while loop. What i want to achieve is like below;
Date Period
09.01.2019 177
10.01.2019 178
11.01.2019 179
12.01.2019 180
01.01.2020 181
Dates keep going until 09.01.2021.
I am using the below script but somehow it ignores do while loop and gets nothing upon finishing.
let vConcat='';
let vStartDate = date('09/01/2019','MM/DD/YYYY');
let vEndDate = date('09/01/2021','MM/DD/YYYY');
let vPeriod = 177;
do while $(vStartDate)<=$(vEndDate)
$(vConcat)
period_table:
load
* inline [
date, period
$(vStartDate),$(vPeriod)
];
let $(vStartDate) = Date(AddMonths($(vStartDate),1),'MM/DD/YYYY');
let $(vPeriod) = $(vPeriod) +1;
let vConcat='Concatenate';
loop;
Edit: I've found it. It was because of $ dollar sign expressions.
1,971 Views
1 Solution
Accepted Solutions

MVP
2019-11-05
08:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also do this using While loop like this
LET vStartDate = Num(Date#('09/01/2019','MM/DD/YYYY'));
LET vEndDate = Num(Date#('09/01/2021','MM/DD/YYYY'));
LET vPeriod = 177;
period_table:
LOAD MonthStart($(vStartDate), IterNo()-1) as date,
$(vPeriod) + IterNo() - 1 as period
AutoGenerate 1
While MonthStart($(vStartDate), IterNo()-1) <= $(vEndDate);
1,935 Views
1 Reply

MVP
2019-11-05
08:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also do this using While loop like this
LET vStartDate = Num(Date#('09/01/2019','MM/DD/YYYY'));
LET vEndDate = Num(Date#('09/01/2021','MM/DD/YYYY'));
LET vPeriod = 177;
period_table:
LOAD MonthStart($(vStartDate), IterNo()-1) as date,
$(vPeriod) + IterNo() - 1 as period
AutoGenerate 1
While MonthStart($(vStartDate), IterNo()-1) <= $(vEndDate);
1,936 Views
