Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Question about calendar

Hi to all, in my QV document I'm using a solution find in this forum to create a calendar in order to select months and years in my document.

The script is the following

UNQUALIFY DateID;

Date_src:

LOAD

$(StartDate) + ROWNO() -1 AS DateId

AUTOGENERATE $(NumOfDays);

Calendar:

LOAD    

         DateId                                                                                       AS DateId      // just in case

        ,DATE(DateId)                                                                                                // in format defined in your SET DateFormat=, or in your system format

        ,DAY(DateId)                                                                                  AS Day

        ,WEEK(DateId)                                                                                 AS Week_S

        ,YEAR(DateId) & NUM(MONTH(DateId), '00') & NUM(DAY(DateId),'00')                              AS DateID

        ,MONTH(DateId)                                                                                AS Month_S    // simple month name; it is dual - numeric and text

        ,DUAL(MONTH(DateId) & '-' & YEAR(DateId), YEAR(DateId) & NUM(MONTH(DateId), '00'))            AS MonthYear   // Month-Year format, dual

        ,YEAR(DateId)                                                                                 AS Year_S

        ,WEEKDAY(DateId)                                                                              AS Weekday

        ,'Q' & CEIL(MONTH(DateId)/3)                                                                  AS Quarter     // in format Q1, Q2, Q3, Q4

        ,DUAL('Q' & CEIL(MONTH(DateId)/3) & '-' & YEAR(DateId), YEAR(DateId) & CEIL(MONTH(DateId)/3)) AS QtrYear     // Qn-Year, dual

RESIDENT Date_src;

DROP TABLE Date_src;

LET NumOfDays = null();

with the following activities in my Main script

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep='.';

SET MoneyDecimalSep=',';

SET MoneyFormat='€ #.##0,00;-€ #.##0,00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='gen;feb;mar;apr;mag;giu;lug;ago;set;ott;nov;dic';

SET DayNames='lun;mar;mer;gio;ven;sab;dom';

LET StartDate = floor(YearStart(AddMonths(today(), -12*5)));

LET EndDate = floor(YearEnd(today()));

LET NumOfDays = EndDate - StartDate + 1;

I'd like to dinamically set StartDate  and EndDate reading two columns in my db.

Can someone suggest me a way to do that?

Thank you in advance for your help.

Best regards

Fabrizio

2 Replies
Gysbert_Wassenaar

See this blog post: The Master Calendar


talk is cheap, supply exceeds demand
Not applicable
Author

Here's an example QVW that I use to create my calendars, I also use this to create multiple master calendars based on differing date fields. You can use the selection to toggle between which date field you'd like to base the selections on.