Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
vchuprina
New Contributor II

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?

1 Solution

Accepted Solutions

Re: How load only last sheet from file?

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

2 Replies

Re: How load only last sheet from file?

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

oscarmqz
Contributor III

Re: How load only last sheet from file?

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));

Community Browser