Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts,
What is Iterno()? how it will work please with examples ?
Regards,
Mahesh.
Iterno() is nothing but the number of iteration you want to perform to calculate some values. iterno() always work with while statement.
for eg
ID StartDate EndDate
1 1/1/2015 2/4/2015
2 2/3/2013 10/5/2015
Now for above data if you wan to fill out the all Dates between StartDate and EndDate to get the Single Date field you can use iterno() like below
Data:
LOAD ID,
(StartDate +iterno()-1) as Date,
FROM Table
While StartDate +iterno()-1 <= EndDate;
So for Each ID , (EndDate- StartDate) iteration will be performed to get the Date
Iterno() is nothing but the number of iteration you want to perform to calculate some values. iterno() always work with while statement.
for eg
ID StartDate EndDate
1 1/1/2015 2/4/2015
2 2/3/2013 10/5/2015
Now for above data if you wan to fill out the all Dates between StartDate and EndDate to get the Single Date field you can use iterno() like below
Data:
LOAD ID,
(StartDate +iterno()-1) as Date,
FROM Table
While StartDate +iterno()-1 <= EndDate;
So for Each ID , (EndDate- StartDate) iteration will be performed to get the Date
Just to be different
For(i=1;i<=10 ;i++)
{
Some code;
}
Here i is the incremental counter,
thats how Iterno() also works in a loop like while or for in Qlikview, it will give the current iteration number
Data:
LOAD ID,
(StartDate +iterno()-1) as Date,
FROM Table
While StartDate +iterno()-1 <= EndDate;
why we use (-1) in above statements? please explain the execution?
Let us assume Start Date is 01 - Jan - 2017 End Date is 10-Jan-2016 and we want to have all the dates between
StartDate and EndDate
For first iteration if you don' use - 1
it becomes
Load ID,
02-Jan-2017 as Date
....
While 02-Jan - 2017 <= 10-Jan-2017;
and for further iterations you will be getting the dates as
2 - Jan - 2017 Iteration 1
3 - Jan -2017 Iteration 2
..
.
.
.
.
10 - Jan -2017 Iteration - 9
If you see we are missing 01 - Jan - 2017 Date, I think for the requirement they want 01 - Jan -2017 Date also
Hope It is clear
But don't ask a question in a corrected answer , pick the code here and point to this thread and start a new thread