Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Dynamically import table from excel sheet

Hi All,

I have an excel datasource in which data is coming in format, attached is the screenshot. I received this excel file on daily basis and want to pull data only from table containing table name "PQR". Since, the files are changing row number of that table is also changing.

So, how can I implement this in qlikview. Please help.

Thanks in Advance.

   

Tags (1)
12 Replies
Employee
Employee

Re: Dynamically import table from excel sheet

Hello,

'POR' should be a value of a new column for each table. So it's easy to read it with Qlikview.

Hope this helps!

balrajahlawat
Esteemed Contributor

Re: Dynamically import table from excel sheet

Is this First time you are loading this excel file?

MVP
MVP

Re: Dynamically import table from excel sheet

Please upload a sample of the spreadsheet. You can load this in Qlikview, but the details are a little complicated. The screenshot is not very useful and without a sample, you might not get any accurate answers.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Dynamically import table from excel sheet

I am attaching a sample file for your reference.

In the attached file I have three tables with table header (Transaction 1, Transaction 2, Transaction3...) and always I want to load data from transaction 2. How will I achieve this.

vikasmahajan
Honored Contributor III

Re: Dynamically import table from excel sheet

you want this https://community.qlik.com/thread/197094 ?

Please check if helped..

Thanks

Vikas

Not applicable

Re: Dynamically import table from excel sheet

Hi,

Add this to script. Gave me what I think you looking for but as Jonathan pointed out, will need more detail if it does not as this can get a little complicated to dynamically account for

PQRRowsTABLE:                             

LOAD *, RowNo() as PQRRows                              

FROM                        

[directory\commdata.xlsx]                             

(ooxml, no labels, table is Sheet1);                            

                                   

            PQRStartEnd:            

            LOAD PQRRows as PQRStartEnd              

            RESIDENT PQRRowsTABLE                      

            WHERE A = 'PQR' or A = 'MNO';                

                                   

            LET zRowStart = Peek('PQRStartEnd',0)+2;                       

            LET zRowEnd = Peek('PQRStartEnd',1);                

                                   

PQRData:                              

LOAD                         

            A          as        No,

            B          as        Name,

            C         as        Gender,

            D         as        Address,

            E          as        Phone

RESIDENT PQRRowsTABLE                                  

WHERE PQRRows >= $(zRowStart) and PQRRows < $(zRowEnd) and (not isnull(A) or A='');                           

DROP TABLES PQRRowsTABLE, PQRStartEnd;                         

                                   

exit script;                   

Not applicable

Re: Dynamically import table from excel sheet

Hi Vikas,

Thanks for sharing above line, but it doesn't work for me. In my case I have a file ,say Transaction 02-02-2016.xlsx. This files contain data divided in table format. Sample excel files has been attached above. I want to load data from single table "Transaction 2" and leave other tables untouched.

Re: Dynamically import table from excel sheet

Hi,

Try something like below,

Temp:

LOAD

RecNo() as DataStart

From Format.xlsx

(ooxml, No Labels, Table is Sheet1)

WHERE A = 'Transaction2';

LET vHeaderSize = Peek('DataStart');

DROP TABLE Temp;

Data:

LOAD [Job ID]

  ,[Job Name]

  ,[Job Start Date]

  ,[Job End Date]

  ,[job status]

From Format.xlsx

     (ooxml, embedded Labels, Header is $(vHeaderSize) Lines, Table is Sheet1)

     Where Not IsNull([Job Name]) and  [Job ID] <>'Job ID' ;

Sample QVW file attached against your file. Let me know

Not applicable

Re: Dynamically import table from excel sheet

Close but this extends to transaction 3 which OP does not want, only transaction 2. Hence why I loaded a start and end

Community Browser