Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

composite key

Please find the attached dashboard.

Where i am creating a composite key and need to get the year and month field selected simaltnaeously in the application.

I want year & month as filters.

I need 2012 jan to be filtered in the list box.

Please let me know

8 Replies
Anonymous
Not applicable
Author

you donot have data from 2012

I would recommend to use a master calender

sushil353
Master II
Master II

Hi,

It is better if you create master calendar in your application.

Anonymous
Not applicable
Author

Thanks for the reply

Could you please provide me sample code for master calendar?

its_anandrjs

Try this master calendar script code

DateData:

LOAD

YearStart( Today() ) + IterNo() as Date,

Rand() as Value

AutoGenerate 1

While (YearStart(Today()) + IterNo())  <= YearEnd(Today());

Final:

Load

*,

Date(Date) as DateNew

Resident DateData;

Master Calendar Generation Script

https://community.qlik.com/blogs/qlikviewdesignblog/2012/10/16/the-master-calendar

Regards

Anand

rubenmarin

Hi John, check this document: Master Calendar Generation Script

In this part of the script:

Load

    Min(InvoiceDate) AS MinDate,

    Max(InvoiceDate) AS MaxDate

RESIDENT Invoice;

MinDate should store the start date of the calendar and MaxDate the end date, it can be dynamic absed on data like in the sample, you can fixed the dates using Date('YourDate') or you can create a variable that sets the min and max dates and use the variables to assign values to MinDate and MaxDate.

Anonymous
Not applicable
Author

Thanks everyone

However in my application i have only year and month i dont have any date field.

Please respond now

rubenmarin

Hi John, you can create only one record per month changing from:

Load Date(MinDate + IterNo() -1 ) AS InvoiceDate While (MinDate + IterNo() - 1) <= Num(MaxDate);


to:

Load Date(AddMonths(MinDate, IterNo() -1)) AS InvoiceDate While Date(AddMonths(MinDate, IterNo() -1)) <= Num(MaxDate);


Anyway, dont' worry too much for creating all dates, as it is another table you can create all dates without affecting your data. and if you load 5-6 years of dates there will be less than 2k extra records.

its_anandrjs

I suggest some of the main points

1. Make Master Calendar

2. To connect with the Date field create the date field with Makedate function.

Ex:-

Load

Makedate(Year, Month) as Datefield

From Location;

Regards

Anand