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: 
Not applicable

How to link master calendar dates to your dates in data

Hi

My requirement is that i have to indicate if an event had occurred on day. It is like a boolean, either i have data for that day or i do not have data for that day. For this i had to create and use master calendar so that all the dates for a given month are there (irrespective of whether i have the data for that day or not). If I have data for that day I have to mark that data is available (any kind of visualization like bar or line chart is okay) and if i don't have data i could leave it blank by not marking anything.

What I tried:

1. On X-Axis i had dates from my data (not master calendar) and selected Continuous axis which put all the dates (though i don't have data for a day). But the problem is that scroll bar does not appear and x-axis scale is automatically set and i have no control over it.

2. I used master calendar, which puts all the dates on X-axis but i have a problem in linking my data to master calendar dates (both are two different tables and have no link with each other).

Thanks for your support in advance.

1 Solution

Accepted Solutions
shanemichelon
Partner - Creator II
Partner - Creator II

I think the solution I have provided is exactly what you want.  If so please mark as correct answer.  If not, please provide feedback.  To give you a little more detail about how the result is achieved, here is the script:

Load * inline [
Facts_Dates,EventOccured
1 July 2013,1
2 July 2013,1
3 July 2013,1
4 July 2013,1
6 July 2013,1
7 July 2013,1
10 July 2013,1
11 July 2013,1
];

The expression used for the bars is:

if(Count(EventOccured)=0,Dual('No Data',Max(total Aggr(Count(EventOccured),Facts_Dates))/2),Count(EventOccured))

The dimension is simply dates taken from a master calendar:

QuartersMap: 

MAPPING LOAD  

rowno() as Month, 

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

AUTOGENERATE (12); 

 

Temp: 

Load 

               min([Facts_Dates]) as minDate, 

               max([Facts_Dates]) as maxDate 

Resident Facts; 

 

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 [Facts_Dates], 

               week(TempDate) As Week, 

               Year(TempDate) As Year, 

               Month(TempDate) As Month

Resident TempCalendar 

Order By TempDate ASC; 

Drop Table TempCalendar;

View solution in original post

24 Replies
jpenuliar
Partner - Specialist III
Partner - Specialist III

You will have to rename your Master Calendar Key Field same as the date field in your fact to create a link

e.g.

Tempdate as Field,

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

It might help to post a sample App.

Also I would imagine there should be something like EVENT_DATE from the Fact table. If there is I will link EVENT_DATE with master calendar.


MK_QSL
MVP
MVP

Can you provide little sample data to work on your example?

Not applicable
Author

Hi all

Thanks for your quick responses. Attached is the sample app. There are two tables in it Facts and Master Calendar. Notice that in Facts_Dates list the dates 8th, 9th and 16th are missing. But Test_Facts_Dates list all the dates are present. Now the x-axis has Test_Facts_Dates, but i have to indicate that on 8th, 9th and 16th there is no data (as there are no entries Facts_Dates).

Not applicable
Author

Thanks for your reply Jonathan. This is a problem for me because my original data gets mixed up with dates i created and i can never separate them.

jpenuliar
Partner - Specialist III
Partner - Specialist III

Change the code:

Date(TempDate,'YYYY-MM-DD') AS [Test_Facts_Dates],

to

Date(TempDate,'YYYY-MM-DD') AS [Facts_Dates],

jpenuliar
Partner - Specialist III
Partner - Specialist III

Your Fields have to be the same Name to establish a link

Not applicable
Author

rename Test_Fact_Dates to Fact_Dates and try to plot Fact_Dates on X-axis of your graph.

--

amay

Not applicable
Author

Thank you Jonathan for your suggestion. But, this might be a problem for me because my original data (Facts_Dates) gets mixed up with dates i created (Test_Facts_Dates) and i can never separate them. Also I have many graphs using Facts_Dates as expressions (for example - Count([Facts_Dates]))) and dimensions. They might not work as expected if i do this.