Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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

but that doesnt explain why the 1 is there when it shouldnt...

amarch.png

sunny_talwar

Not sure why, but right now you have an issue with your Key field

Capture.PNG

Second row should say 01/03/201611787 instead of 29/02/201611787

sunny_talwar

I think the script is missing Table AA, so I won't be able to test it out unless you provide me the source data.

matthewp
Creator III
Creator III
Author

i respectfully disagree, I think its from the calendar

i think when we create the key field:

key field = Adate + number

Adate = TempDate

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

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


minDate = min([HA Date From])



So if there is no entry for 29/02/2016 in [HA Date From] i think this is causing us issues?


sunny_talwar

I am not saying that we have done anything wrong, but I am just saying that there is something weird going on when we create the key (I agree that it is within the calendar). But until and unless we fix the key, you will continue to see incorrect results. Does that make sense? All I am asking is, if you can provide me access to AA table?

matthewp
Creator III
Creator III
Author

I'll build something now,

duration

date from

date to

are already i there, what other fields do you need?

sunny_talwar

I just need the ability to reload this which I won't be able to do without table AA in the script and its source. It can be a simple inline table is what I all need

matthewp
Creator III
Creator III
Author

ohh the source data table! let me make one!

Does this work

edit:

AA:

LOAD * INLINE [

Number, Name, HA Abs Duration, HA Date From, HA Date To,

11553, Peter Doe, 1, 27/01/2016 00:00:00, 27/01/2016 00:00:00

11553, Peter Doe, 2, 12/02/2016 00:00:00, 15/02/2016 00:00:00

11553, Peter Doe, 1, 26/02/2016 00:00:00, 26/02/2016 00:00:00

11787, John Smith, 1, 29/02/2016 00:00:00, 29/02/2016 00:00:00

11553, Peter Doe, 0.5, 10/03/2016 00:00:00, 10/03/2016 00:00:00

11553, Peter Doe, 1, 01/04/2016 00:00:00, 01/04/2016 00:00:00

11787, John Smith, 0.5, 15/04/2016 00:00:00, 15/04/2016 00:00:00

11553, Peter Doe, 0.5, 18/04/2016 00:00:00, 18/04/2016 00:00:00

11553, Peter Doe, 1, 29/04/2016 00:00:00, 29/04/2016 00:00:00

11787, John Smith, 1, 27/05/2016 00:00:00, 27/05/2016 00:00:00

11787, John Smith, 15, 20/06/2016 00:00:00, 08/07/2016 00:00:00

11787, John Smith, 1, 18/07/2016 00:00:00, 18/07/2016 00:00:00

11787, John Smith, 1, 05/08/2016 00:00:00, 05/08/2016 00:00:00

11553, Peter Doe, 6, 02/09/2016 00:00:00, 09/09/2016 00:00:00

];

sunny_talwar

Here try this change in your application:

Floor(ADate)&[Number] as Key

FinalMasterCalendar:

LOAD *,

  Floor(ADate)&[Number] as Key

Resident MasterCalendar;

matthewp
Creator III
Creator III
Author

Excellent!

Can you explain what was happening so i can understand better for the future