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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
avastani
Partner - Creator III
Partner - Creator III

Script help

I have a table where there are multiple addresses for each company but I want to extract records for only those addresses that were added last. I know they were added last by the LastUpdateDate field. How can I do that? Subqueries is not an option as QV doesn't permit that and a for loop would take forever in a table with 2m+ records. Is there any other option.

Thanks in advance.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

If you're reading the table with SQL, I don't see why subqueries or some other approach on the database side wouldn't work, but you can also handle it in QlikView. There is almost certainly a more efficient method, but this seems straightforward enough:

[Companies]:
LOAD
"Company ID"
,"Last Update Date"
,"Company Address"
FROM ...
;
INNER JOIN ([Companies])
LOAD
"Company ID"
,max("Last Update Date") as "Last Update Date"
RESIDENT [Companies]
GROUP BY "Company ID"
;
DROP FIELD "Last Update Date"
;

View solution in original post

2 Replies
johnw
Champion III
Champion III

If you're reading the table with SQL, I don't see why subqueries or some other approach on the database side wouldn't work, but you can also handle it in QlikView. There is almost certainly a more efficient method, but this seems straightforward enough:

[Companies]:
LOAD
"Company ID"
,"Last Update Date"
,"Company Address"
FROM ...
;
INNER JOIN ([Companies])
LOAD
"Company ID"
,max("Last Update Date") as "Last Update Date"
RESIDENT [Companies]
GROUP BY "Company ID"
;
DROP FIELD "Last Update Date"
;

avastani
Partner - Creator III
Partner - Creator III
Author

Thanks John. My brain was so fried, I couldn't think straight. I have another datamodel problem in another thread if you could please help take a look, I would appreciate it. Thanks again.