Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I try to load 2 tables in my QV document. Both are Excel files. In the first table I load dates when a customer starts and ends a subscription with us. Example:
Subscription | Customer_Id | StartDate | EndDate |
---|---|---|---|
1 | 10 | 01-01-2015 | 31-10-2015 |
2 | 6 | 01-05-2014 | 30-04-2015 |
3 | 8 | 01-08-2014 | 31-08-2014 |
In the second table i load the birthdate of the customer: Example:
Customer_Id | Name | Date_of_Birth |
---|---|---|
6 | Jan | 05-05-2001 |
8 | John | 21-07-1963 |
10 | Sanne | 16-11-1988 |
Now i want to load in one of the tables the age of the customer when he started his subscription. This is easier in the rest of the document so i don't need to calculate the age in every chart i will use it.
I hope somebody can help me with this!
Thanks in advance.
Table2:
Load Customer_Id, Name, Date_of_Birth
from Table2.xls
[....];
Map_DOB:
Mapping Load
Customer_Id, Date_of_Birth
resident Table2;
Table1:
load Subscription, Customer_Id, StartDate, EndDate, Year(Date#(StartDate,'DD-MM-YYYY') - Year(Date#(Applymap('Map_DOB',Customer_Id,null()),'DD-MM-YYYY') as AgeAtStart
from Table1.xls
[....];
Left join the 2 tables, in this way you will have the date of Birth of each customes in any row of subscriptios table.
Now reload the table (Ex. MyTable) and use the age function:
FinalTable:
Load
...
age(start-date, date_of_birth)
...
Resident MyTable;
drop table myTable;
Let me know
Table2:
Load Customer_Id, Name, Date_of_Birth
from Table2.xls
[....];
Map_DOB:
Mapping Load
Customer_Id, Date_of_Birth
resident Table2;
Table1:
load Subscription, Customer_Id, StartDate, EndDate, Year(Date#(StartDate,'DD-MM-YYYY') - Year(Date#(Applymap('Map_DOB',Customer_Id,null()),'DD-MM-YYYY') as AgeAtStart
from Table1.xls
[....];
Thanks Simen,
I do calculate the age with the Age() function! But the Mapping Load function works! Thank you very much!