Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
konidena
Creator
Creator

Iterno() function

Hi Team,

I am confusing about the usage of Iterno() usage.

This is the function used to generate the integer value. We generally use this function with while statement when we create the master calendar..

I have a question here.

Calendar script:

LET vDateMin = Num(MakeDate(2008,1,1));

LET vDateMax = Floor(DayEnd(Today()));

LET vDateToday = Num(Today());

TempCalendar:

LOAD

$(vDateMin) + RowNo() - 1 AS DateNumber,

Date($(vDateMin) + RowNo() - 1) AS TempDate

AUTOGENERATE 1

WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);

1. in the above script, why we use -1 in the while statement.

2. Why we using Autogenerate here. Is there any relation to IterNo() and Autogenerate function.

Regards

Srinivas

2 Replies
trdandamudi
Master II
Master II

Please see below for the answers:

1. in the above script, why we use -1 in the while statement.

     The reason you use -1 because the IterNo() will start from 1.

     For example if your DateMin is 07/30/2016:

     Then WHILE $(vDateMin)+IterNo()-1 will become  07/30/2016 (07/30/2016 + 0)

     If you use WHILE $(vDateMin)+IterNo() then it will become 07/31/2016  (07/30/2016 + 1)

2. Why we using Autogenerate here. Is there any relation to IterNo() and Autogenerate function.

     You are using Autogenerate because you want to generate one row for each date between minimum and maximum      date.

Please look into help for more detail explanations. Hope this helps..

Digvijay_Singh

1. You want to start from Minimum date, if you don't use -1, it will start from 2nd date from beginning.

2. For each date script is generating one record and then advancing to another date with the help of Iterno().

Normally there is a preceding load(one more load on top of your script) so that for each autogenerated record, other fields like month, year, quarter can be created in a individual date record.