Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
vchuprina
Specialist
Specialist

How load only last sheet from file?

Hi All,

Every week I'm receiving files with multiple sheets, but I need to load data only from the last one.

Problem that each sheets has own name and these names are different from week to week, for example:Безымянный.png

How I can load data only from the last sheet?

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
1 Solution

Accepted Solutions
marcus_sommer

See here an example how do you could load multiple sheets.

https://community.qlik.com/docs/DOC-7860

I'm not sure if it's possible to recognize within the sheet-table the last or newest sheet but if there isn't an unique indicator then you could store the already loaded sheetnames and check these within an if-loop if they match with the available sheets or not.

- Marcus

View solution in original post

2 Replies
marcus_sommer

See here an example how do you could load multiple sheets.

https://community.qlik.com/docs/DOC-7860

I'm not sure if it's possible to recognize within the sheet-table the last or newest sheet but if there isn't an unique indicator then you could store the already loaded sheetnames and check these within an if-loop if they match with the available sheets or not.

- Marcus

Anonymous
Not applicable

Just putting here the code to do so using part of what Marcus shared

set file = '[PATH]\[FILE].xlsx';

ODBC CONNECT32 TO [Excel Files;DBQ=$(file)];

tables:

SQLtables;

DISCONNECT;

Last:

first 1

load

    TABLE_NAME

resident tables

order by TABLE_NAME DESC;

let LastTab = replace(Peek('TABLE_NAME',0,'Last'),'$','');

drop Tables tables,Last;

LOAD *

FROM

[[PATH]\[FILE].xlsx]

(ooxml, embedded labels, table is $(LastTab));