Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mauvasco62
Contributor III
Contributor III

Iterno() with months in Qlik Sense

Dear all,

i need your support in order to solve a "little" problem.

I have a table like this

KEYID       Start                          End                                  etc       etc

1                 01/12/2019              31/03/2020                alfa      beta

2                 01/02/2020              31/03/2020                sdfs     gddd

3                 01/01/2020               29/02/2020                uytt    uyyyy

 

For every KEYID i would like to create many lines as there are months of validity using a cycle.

The final result must be (for the KEYID 1) something like this

KEYID   Start                              End                      Year validity    Month validity   etc   etc

1             01/12/2019                31/03/2020       2019                    12                           alfa      beta

1             01/12/2019                 31/03/2020        2020                  01                           alfa      beta

1            01/12/2019                  31/03/2020        2020                  02                           alfa      beta

1            0/12/2019                    31/03/2020        2020                  03                           alfa       beta

Thanks in advance for your help

Regards

Mauro

1 Solution

Accepted Solutions
Kushal_Chawda

@mauvasco62  try below

Data
LOAD KEYID,    
     Start,     
     year(monthstart(Start,iterno()-1)) as Year ,
     month(monthstart(Start,iterno()-1)) as Month                  
     End,
     etc1,
     etc2
FROM Table
while monthstart(Start,iterno()-1)<=End; 

View solution in original post

3 Replies
Taoufiq_Zarra

@mauvasco62  like this for example ?

Data:
load * inline [
KEYID,Start,End,etc,etc1

1,01/12/2019,31/03/2020,alfa,beta

2,01/02/2020,31/03/2020,sdfs,gddd

3,01/01/2020,29/02/2020,uytt,uyyyy
];

left join 
load distinct KEYID,Num(Month(Date(Start + IterNo() - 1)),'00')    as [Month validity],Year(Date(Start + IterNo() - 1)) as [ Year validity] resident Data  While Start + IterNo() - 1 <= End;



 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Kushal_Chawda

@mauvasco62  try below

Data
LOAD KEYID,    
     Start,     
     year(monthstart(Start,iterno()-1)) as Year ,
     month(monthstart(Start,iterno()-1)) as Month                  
     End,
     etc1,
     etc2
FROM Table
while monthstart(Start,iterno()-1)<=End; 
mauvasco62
Contributor III
Contributor III
Author

Thank you Kush,

it works fine.

Have a nice day

Mayri