Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Sameer9585
Creator II
Creator II

Max Table name

Hi,

I have situation where it is that there are few table names date wise and I need to get the data of max table name.

Means if I had table names as Sales_1/1/2019,Sales_2/1/2019,Sales_3/1/2019,Sales_4/1/2019...now I need a script in that a way that to give it should display tables Sales_4/1/2019 which is the max one in this.

 

Thanking You in advance,

1 Solution

Accepted Solutions
PrashantSangle

if all files in same location then try below code
Set $(vexcelpath)='c:\docuement\';

FileName:
First 1
LOAD SubField(FileBaseName(),'_',2) as fileName
FROM [lib://$(vexcelpath)\*.xlsx]
(ooxml, embedded labels, table is Sheet1);

maxDateFile:
Load max(fileName) as maxDate Resident FileName;

Let vMaxFileName = Peek('maxDate',0,'maxDateFile');

Final_Load:
Load * from FROM [lib://$(vexcelpath)\Sale_$(vMaxFileName).xlsx]
(ooxml, embedded labels, table is Sheet1);

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

1 Reply
PrashantSangle

if all files in same location then try below code
Set $(vexcelpath)='c:\docuement\';

FileName:
First 1
LOAD SubField(FileBaseName(),'_',2) as fileName
FROM [lib://$(vexcelpath)\*.xlsx]
(ooxml, embedded labels, table is Sheet1);

maxDateFile:
Load max(fileName) as maxDate Resident FileName;

Let vMaxFileName = Peek('maxDate',0,'maxDateFile');

Final_Load:
Load * from FROM [lib://$(vexcelpath)\Sale_$(vMaxFileName).xlsx]
(ooxml, embedded labels, table is Sheet1);

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂