Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
qliknexus_kgcru
Partner - Contributor III
Partner - Contributor III

self-join to create measure

Hi

I need to able to create measures based on the first 3 columns, i need to create 3  measures (AMOUNT_NEXTDATE2, AMOUNT_NEXTDATE3, AMOUNT_NEXTDATE4)


the AMOUNT_NEXTDATE2/3/4's value should be based on the next month


e.g. DATE_2 20160201 AMOUNT 10, value for AMOUNT_NEXT  DATE2 should be 20 because the value for 20160301 is 20 which is the next month.

i tried doing a self-join but it doesn't work well for me. Any help? thanks!

DATE_1DATE_2AMOUNTAMOUNT_NEXT  DATE2AMOUNT_NEXT  DATE3AMOUNT_NEXT  DATE4
201708012016020110203040
201708012016030120304050
201708012016040130405060
201708012016050140506070
201708012016060150607080
201708012016070160708090
2017080120160801708090100
20170801201609018090100110
201708012016100190100110120
2017080120161101100110120130
2017080120161201110120130140
2017080120170101120130140150
2017080120170201130140150160
2017080120170301140150160170
2017080120170401150160170180
1 Reply
Saravanan_Desingh

One solution is:

tab1:
LOAD DATE_1, 
     DATE_2, 
     AMOUNT, 
	 DATE_1&'@'&DATE_2 As Key1,
	 DATE_1&'@'&Date(AddMonths(Date#(DATE_2,'YYYYMMDD'),1),'YYYYMMDD') As Key2,
	 DATE_1&'@'&Date(AddMonths(Date#(DATE_2,'YYYYMMDD'),2),'YYYYMMDD') As Key3,
	 DATE_1&'@'&Date(AddMonths(Date#(DATE_2,'YYYYMMDD'),3),'YYYYMMDD') As Key4	 	 
FROM
[C:\Users\sarav\Downloads\TEST DATA.xlsx]
(ooxml, embedded labels, table is Sheet1);

Left Join(tab1)
LOAD Key1 As Key2, AMOUNT As [AMOUNT_NEXT DATE2]
Resident tab1;

Left Join(tab1)
LOAD Key1 As Key3, AMOUNT As [AMOUNT_NEXT DATE3]
Resident tab1;

Left Join(tab1)
LOAD Key1 As Key4, AMOUNT As [AMOUNT_NEXT DATE4]
Resident tab1;

Drop Field Key1, Key2, Key3, Key4;

commQV30.PNG