Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
colinodonnel
Creator II
Creator II

MasterCalender per ID

Hello there,

I have the following table:

IDMin DateMax Date
101/01/201805/01/2018
202/01/201805/01/2018

 

From this, how can I create the following table?:

IDDate
101/01/2018
102/01/2018
103/01/2018
104/01/2018
105/01/2018
202/01/2018
203/01/2018
204/01/2018
205/01/2018

 

There are lots of posts on creating a Master Calendar so I have script to create between a single min/max date.

But the twist is,  I need the MasterCalendar script to repeat for each new ID, and to concatenate the results into one table.

Thank you,

Colin

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Assuming your Min and Max date are in format DD/MM/YYYY... you can try this

Table:
LOAD ID,
	 Date([Min Date] + IterNo() - 1) as Date
While [Min Date] + IterNo() - 1 <= [Max Date];
LOAD * INLINE [
    ID, Min Date, Max Date
    1, 01/01/2018, 05/01/2018
    2, 02/01/2018, 05/01/2018
];

View solution in original post

2 Replies
sunny_talwar
MVP
MVP

Assuming your Min and Max date are in format DD/MM/YYYY... you can try this

Table:
LOAD ID,
	 Date([Min Date] + IterNo() - 1) as Date
While [Min Date] + IterNo() - 1 <= [Max Date];
LOAD * INLINE [
    ID, Min Date, Max Date
    1, 01/01/2018, 05/01/2018
    2, 02/01/2018, 05/01/2018
];
colinodonnel
Creator II
Creator II
Author

Hi Sunny,

Thanks for this.

What a beautifully succinct bit of code.

 

I don't fully understand how it works.

Would you kindly explain how / why it creates the new rows one ID at a time (a bit like a loop maybe?)

Thanks, Colin