Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
How I can load data only from the last sheet?
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
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
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));