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: 
Gabri
Contributor III
Contributor III

Add field (firstInvoice)

Hi, I want to add a new field on load data from SQL with name (firstInvoice), for example, I have to tables:

CLIENTS  
CLIENTIDNAME 
1AA 
2BB 
3CC 
   
   
INVOICES  
CLIENTIDDATEAMOUNT
107/02/201810
209/02/201815
110/05/201910
215/06/201920
205/09/201920
305/01/202010
115/01/202010
120/01/202020
201/02/202010
304/02/202010
306/02/202020

 

For each client I need to say  [ SELECT min(year(DATE) from INVOICES) as firstInvoice ]

The desired result is:

CLIENTS  
CLIENTIDNAMEfirstInvoice
1AA2018
2BB2018
3CC2020

 

Thanks in advance!

13 Replies
sunny_talwar

Does this table also have the same CODCLI  "bd1".dbo.CLIENTS as do "bdi".dbo.CABEFACV? The join will only work if the field values align. For example, if one table has 2, 4, 6 and the other one have 1, 3, 5... the join will not work

Gabri
Contributor III
Contributor III
Author

"bd1".dbo.CLIENTS have all clients, so have (1,2,3,4,5.....)

"bdi".dbo.CABEFACV have all invoices, so its possible that have (2,3,3,3,4,8...)

 

sunny_talwar

It should have worked, but I am not sure why it hasn't.

Gabri
Contributor III
Contributor III
Author

Hello, I've been testing and finally with a new table, only with (cliendid, firstInvoice), and it works !

 

[CLIENTESFI]:
LOAD * INLINE [CLIENTID];
SELECT CLIENTID FROM "bd1".dbo.CLIENTES; 
LEFT JOIN(CLIENTESFI)
LOAD CLIENTID, Min(Year(DATE)) as firstInvoice GROUP BY CLIENTID;
SELECT CLIENTID, DATE FROM "bd1".dbo.INVOICES; 

 

 

Thanks for your time!

Best regards,

Gabri