Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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

Yeh its a different approach to it for sure!

One more thing, the total column isnt adding the 0.5 duration days as it should.

to handle this in the expression i use:

IF(duration = 0.5, (Sum(Aggr(RangeSum(

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

Avg({<Key = {"=Len(Trim(datefrom)) = 0"}>}0)), name, Date))/2),

Sum(Aggr(RangeSum(

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

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


which works for the main data but not for the total column (show partial sums)

matthewp
Creator III
Creator III
Author

are partial sums unavailable to do decimals?

sunny_talwar

Trying it out now

sunny_talwar

Try this out:

Sum(Aggr(IF(duration = 0.5, (RangeSum(

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

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

RangeSum(

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

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

sunny_talwar

And why not just this

Sum(Aggr(IF(duration = 0.5, 0.5,

RangeSum(

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

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

matthewp
Creator III
Creator III
Author

Brilliant!

matthewp
Creator III
Creator III
Author

Getting a strange issue with one of them,

i am getting a value of 1 in a box but when i look at the data in a table there is no entry for that date

sunny_talwar

Would you be able to share a sample of where you are seeing this

matthewp
Creator III
Creator III
Author

If you look at 1st of march there is an entry for john smith that shouldnt be and disappears if you select the month march

sunny_talwar

John Smith is still 0, but just showing because we are not suppressing zero values in the chart. I guess the issue is that we have not 'Suppress Zero Value' on the presentation tab. If we do that, then we loose all zeros from regular view which is not what you would want.

Capture.PNG