Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Join all dates to table

Colleagues, good day!

I have one simple table (Main) with such fields:

     

IDProductFlagDateSales
1A101.12.201643
1A103.12.201654
1A104.12.20163
1B105.12.20164
1B106.12.20165
2A101.12.201643
2A103.12.201654
2A104.12.20163
2B105.12.20164
2B106.12.20165

Also i have directory with calendar, which contain Date field:

 

Date
01.12.2016
02.12.2016
03.12.2016
04.12.2016
05.12.2016
06.12.2016
07.12.2016

I need to join all dates from directory to every ID, Product, and Flag, in result my result table must have such view:

     

IDProductFlagDateSales
1A101.12.201643
1A102.12.2016-
1A103.12.201654
1A104.12.20163
1A105.12.2016-
1A106.12.2016-
1A107.12.2016-
1B101.12.2016-
1B102.12.2016-
1B103.12.2016-
1B104.12.2016-
1B105.12.20164
1B106.12.20165
1B107.12.2016-
2A101.12.201643
2A102.12.2016-
2A103.12.201654
2A104.12.20163
2A105.12.2016-
2A106.12.2016-
2A107.12.2016-
2B101.12.2016-
2B102.12.2016-
2B103.12.2016-
2B104.12.2016-
2B105.12.20164
2B106.12.20165

In attachment test files.

many thanks for help!

1 Solution

Accepted Solutions
girirajsinh
Creator III
Creator III

LOAD ID,

    
Product,

    
Flag,

  
//  Date as D_Key,

    // Sales,

     'C' as C_Key

FROM

Dates.xlsx

(
ooxml, embedded labels, table is Main);

join

LOAD Date as D_Key,

'C'
as C_Key

FROM

Dates.xlsx

(
ooxml, embedded labels, table is Dates);



Main:

LOAD ID,

    
Product,

    
Flag,

    
D_Key



Resident subtable;



Left Join

LOAD ID,

    
Product,

    
Flag,

    
Date as D_Key,

    
Sales

    

FROM

Dates.xlsx

(
ooxml, embedded labels, table is Main);



Drop Table subtable;















View solution in original post

4 Replies
girirajsinh
Creator III
Creator III

LOAD ID,

    
Product,

    
Flag,

  
//  Date as D_Key,

    // Sales,

     'C' as C_Key

FROM

Dates.xlsx

(
ooxml, embedded labels, table is Main);

join

LOAD Date as D_Key,

'C'
as C_Key

FROM

Dates.xlsx

(
ooxml, embedded labels, table is Dates);



Main:

LOAD ID,

    
Product,

    
Flag,

    
D_Key



Resident subtable;



Left Join

LOAD ID,

    
Product,

    
Flag,

    
Date as D_Key,

    
Sales

    

FROM

Dates.xlsx

(
ooxml, embedded labels, table is Main);



Drop Table subtable;















girirajsinh
Creator III
Creator III

qvw here

Anonymous
Not applicable
Author

Thanks!

vinieme12
Champion III
Champion III

just one thing that you will need to correct is that the join in the Main table is done basis only on the Date which is not reliable you might want to create a composite key like; ID&Product&Date as KEY  instead of only joining on the date

ALL_Products:

Load distinct Product,

ID,

Flag

FROM

Main;

join

ALL_DATES:

Load Date

FROM

Dates;

NoConcatenate

FACT:

Load *,ID&Product&Date as KEY

RESIDENT ALL_Products;

Drop Table ALL_Products;

Left Join (FACT)

LOAD ID&Product&Date as KEY,

Sales

FROM

Main;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.