Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Two fact tables with different date granularity join to a single calendar

hi qlikers,

Need help on this one.

Originally i had 1 fact table joined to a single master calendar table on key_CalendarDay. It looks something like this.

OppNoValuekeyCalendarDay
ABC1200001001
DFS234001002
FGS34501003
JHU45001004

And my master Calendar table :

keyCalendarDaykeyCalendarWeekkeyCalendarMonthkeyCalendarQtrProcessDateYYYYWKYYYYMMYYYYQYYYY
100110001100001100000101-01-2014201401201401201412014
100210001100001100000101-02-2014201401201401201412014
100310001100001100000101-03-2014201401201401201412014
100410001100001100000101-04-2014201401201401201412014
100510002100001100000101-05-2014201402201401201412014

Now I would need to pull in another fact table, but this time it has a different date granularity , something like this.

OppNoForecastValuekeyCalendarQtr
ABC11230001000001
DFS22010001000001
FGS32300001000001
JHU41203301000001
ABC12000001000002
DFS23000001000002
FGS34000001000002
JHU42000101000002

So the first and second table is joined on key_CalendarDay.

Now i would need to bring in the forecast table (Table3), and link it to the calendar table on keyCalendarQtr.

Any ideas on how I could pull this off ? Do I need to use a link table for this ? if so, how would i do it ?


Thanks.

Shan.

1 Reply
its_anandrjs

Update script now you can check

If you left join your Fact tables and take it into single fact table on the basis of the OppNo field because it is present in both tables. And then create a composite keys based on the keyCalendarDay&'_'&keyCalendarQtr as %Key  and also create this key in the Calendar table then your fact table get connected with the calendar.See the script for this

Temp_Fact:

LOAD * INLINE [

    OppNo, Value, keyCalendarDay

    ABC1, 20000, 1001

    DFS2, 3400, 1002

    FGS3, 450, 1003

    JHU4, 500, 1004

];

Left Join(Temp_Fact)

LOAD * INLINE [

    OppNo, ForecastValue, keyCalendarQtr

    ABC1, 123000, 1000001

    DFS2, 201000, 1000001

    FGS3, 230000, 1000001

    JHU4, 120330, 1000001

    ABC1, 200000, 1000002

    DFS2, 300000, 1000002

    FGS3, 400000, 1000002

    JHU4, 200010, 1000002

];

FinalFact:

LOAD keyCalendarDay&'_'&keyCalendarQtr as %Key,OppNo,Value,ForecastValue Resident Temp_Fact;

DROP Table Temp_Fact;

Cal:

LOAD *,keyCalendarDay&'_'&keyCalendarQtr as %Key;

LOAD * INLINE [

    keyCalendarDay, keyCalendarWeek, keyCalendarMonth, keyCalendarQtr, ProcessDate, YYYYWK, YYYYMM

    1001, 10001, 100001, 1000001, 01-01-2014, 201401, 201401

    1002, 10001, 100001, 1000001, 01-02-2014, 201401, 201401

    1003, 10001, 100001, 1000001, 01-03-2014, 201401, 201401

    1004, 10001, 100001, 1000001, 01-04-2014, 201401, 201401

    1005, 10002, 100001, 1000001, 01-05-2014, 201402, 201401

];

];