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: 
matthewp
Creator III
Creator III

Master calendar that isnt linked to any orderdate etc for chart

i want to create a master calendar that isn't linked to any orderdate or any other table

Let me explain it a bit better as i have been quite ambiguous...

Data sample

namedatefromdatetoduration
john21/12/201524/12/20154
john27/01/201627/01/20161
john12/02/201615/02/20162
john26/02/201626/02/20161
john10/03/201610/03/20160.5
john01/04/201601/04/20161
john18/04/201618/04/20160.5
john29/04/201629/04/20161
john02/09/201609/09/20166

Current (pivot table) output:

cur.png

Current pivot table dimensions:

name

tempdate

Current pivot table expression:

IF(tempdate >= datefrom AND tempdate <= dateto, 1, 0 )

Expected output (shortened) i would like ALL dates shown not just the populated ones:

nametempdate19/12/201520/12/201521/12/201522/12/201523/12/201524/12/201525/12/201526/12/201527/12/201528/12/201529/12/201530/12/201531/12/2015
john0011110000000

ALSO tempdate comes from the master calendar example on here....

QuartersMap:

MAPPING LOAD 

rowno() as Month,

'Q' & Ceil (rowno()/3) as Quarter

AUTOGENERATE (12);

Temp:

Load

               min(datefrom) as minDate,

               max(dateto) as maxDate

Resident newtable;

Let varMinDate = Num(Peek('minDate', 0, 'Temp'));

Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));

DROP Table Temp;

TempCalendar:

LOAD

               $(varMinDate) + Iterno()-1 As Num,

               Date($(varMinDate) + IterNo() - 1) as TempDate

               AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);

MasterCalendar:

Load

               TempDate AS datefrom,

               TempDate AS tempdate,

               week(TempDate) As Week,

               Year(TempDate) As Year,

               Month(TempDate) As Month,

               Day(TempDate) As Day,

               YeartoDate(TempDate)*-1 as CurYTDFlag,

               YeartoDate(TempDate,-1)*-1 as LastYTDFlag,

               inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,

               date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,

               ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,

               Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,

               WeekDay(TempDate) as WeekDay

Resident TempCalendar

Order By TempDate ASC;

Drop Table TempCalendar;

60 Replies
matthewp
Creator III
Creator III
Author

not on the total bit, i havent put that in, before that when we used =Count(DISTINCT name) as the expression

sunny_talwar

Not sure I follow your response. Is this not what you want?

matthewp
Creator III
Creator III
Author

no, going back to this file

https://community.qlik.com/servlet/JiveServlet/download/1096831-239136/Community_227506.qvw

im not using that total column yet, just the =Count(DISTINCT name) as the expression

i want it to show all dates even when a name selection is made as i am using name as a dimension also

sunny_talwar

Unable to get rid of the null row, but if having that there is not an issue, you can try this:

=If(Len(Trim(name)), Count(DISTINCT name) +Avg(TOTAL {1}0))

Capture.PNG

matthewp
Creator III
Creator III
Author

not quite, in that last example you sent.

add a list box for name and then click the name and you can see it only shows 1 values

sunny_talwar

New script (not the best script to use)

Table:

LOAD name,

    datefrom,

    dateto,

    duration

FROM

[https://community.qlik.com/thread/227506]

(html, codepage is 1252, embedded labels, table is @1);

Concatenate(Table)

LOAD 'Rahul' as name,

    datefrom,

    dateto,

    duration

FROM

[https://community.qlik.com/thread/227506]

(html, codepage is 1252, embedded labels, table is @1);

QuartersMap:

MAPPING LOAD 

rowno() as Month,

'Q' & Ceil (rowno()/3) as Quarter

AUTOGENERATE (12);

Temp:

Load min(datefrom) as minDate,

    max(dateto) as maxDate

Resident Table;

Let varMinDate = Num(Peek('minDate', 0, 'Temp'));

Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));

DROP Table Temp;

TempCalendar:

LOAD $(varMinDate) + Iterno()-1 As Num,

    Date($(varMinDate) + IterNo() - 1) as TempDate

AutoGenerate 1

While $(varMinDate) + IterNo() -1 <= $(varMaxDate);

MasterCalendar:

Load TempDate AS Date,

    week(TempDate) As Week,

    Year(TempDate) As Year,

    Month(TempDate) As Month,

    Day(TempDate) As Day,

    YeartoDate(TempDate)*-1 as CurYTDFlag,

    YeartoDate(TempDate,-1)*-1 as LastYTDFlag,

    inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,

    date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,

    ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,

    Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,

    WeekDay(TempDate) as WeekDay

Resident TempCalendar

Order By TempDate ASC;

Drop Table TempCalendar;

Join(MasterCalendar)

LOAD DISTINCT name

Resident Table;

FinalMasterCalendar:

LOAD *,

  Date&name as Key

Resident MasterCalendar;

DROP Table MasterCalendar;

Join(Table)

IntervalMatch(Date, name)

LOAD datefrom,

    dateto,

    name

Resident Table;

Dimensions:

1) name

2) Date

Expression:

RangeSum(

Count({<Key = {"=Len(Trim(datefrom)) > 0"}>}DISTINCT name),

Avg({<Key = {"=Len(Trim(datefrom)) = 0"}>}0))

matthewp
Creator III
Creator III
Author

every  field is now populated with 1's but i think its my fault as my data isnt like the example i gave .slight amendment to the data...

table structure is like this:

tableA

enumdatefromdatetoduration
1221/12/201524/12/20154
1227/01/201627/01/20161
1212/02/201615/02/20162
1226/02/201626/02/20161
1210/03/201610/03/20160.5
1201/04/201601/04/20161
1218/04/201618/04/20160.5
1229/04/201629/04/20161
1202/09/201609/09/20166

tableB

enumname
12john
sunny_talwar

Can you add another enum?

matthewp
Creator III
Creator III
Author

Like this..

tableA

enumdatefromdatetoduration
1221/12/201524/12/20154
1227/01/201627/01/20161
1212/02/201615/02/20162
1226/02/201626/02/20161
1310/03/201610/03/20160.5
1301/04/201601/04/20161
1318/04/201618/04/20160.5
1329/04/201629/04/20161
1302/09/201609/09/20166

tableB

enumname

12

13

john

rahul

sunny_talwar

Yes, thank you