Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Sxbbb
Creator III
Creator III

I used the calendar code and missed two days

I fetch data from excel The latest date is 10/02/2023.

use code

Suchanan_0-1676084096447.png

Result

Suchanan_1-1676084221494.png

But I use this formula for my calendar.

Suchanan_3-1676084467326.png

But the dates 09/02/2023 and 10/02/2023 disappeared

 

Suchanan_4-1676084773165.png

I need E_Date and E_Day data for Listbox.

Suchanan_5-1676085006928.png

 

But the dates 09/02/2023 and 10/02/2023 disappeared
1 Reply
BrunPierre
Partner - Master
Partner - Master

Hi@Sxbbb

You may want to take the min and max dates and build an entry for each date to generate all possible dates.

Something like this.

//******** Extract maximum and minimum date *************************

Temp:
LOAD Max(Date) AS MaxDate,                  
     Min(Date) AS MinDate                  
RESIDENT [GRAND FACT];
                 
//******** Store Minimum and maximum dates as variable ******************
LET varMaxDate = Peek('MaxDate', 0, 'Temp');
LET varMinDate = Peek('MinDate', 0, 'Temp');
//LET varMaxYear = Peek('MaxYear', 0, 'Temp');
//LET varMaxMonth = Peek('MaxMonth', 0, 'Temp');

DROP TABLE Temp;
 
 //******************* Generate all possible dates ***********************
 
TEMP_CALENDER:
LOAD
$(varMinDate)+Iterno()-1 AS Num,
Date($(varMinDate)+Iterno()-1) AS TempDate
AUTOGENERATE 1 WHILE $(varMinDate)+Iterno()-1<=
$(varMaxDate);
//Building the master calendar with most date

//**************** Generate Calender ********************
CALENDER:
LOAD *,
Quarter&'-'&Year AS QuarterYear
;
LOAD
DATE(TempDate,'dd/MM/yyyy') AS Date,    
Year(TempDate) AS Year,
'Q' & ceil(month(TempDate) / 3) AS Quarter,
date(monthstart(TempDate), 'MMM-YYYY') AS MonthYear,
Day(TempDate)AS Day,
Week(TempDate) AS Week,
Month(TempDate) AS Month
RESIDENT TEMP_CALENDER
ORDER BY TempDate Asc;

Drop table TEMP_CALENDER;

EXIT SCRIPT;