Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

qliktech_uk
Not applicable

QVD Load Stats

Hi,

I am using the code below to get the stats, it comes up as syntax error, I am unable to figure out why, your help is much appreciated.

SUB Stats;

LET vEndTime = Now();

LET vRecords = NoOfRows('$(vTable)');

LET vFields = NoOfFields('$(vTable)');

Statistics:

LOAD * From  Statistics.QVD; //where TableName <> '$(vTable)';

Join (Statistics)

LOAD

DISTINCT

     ‘$(vTable)’ AS TableName, 

     ‘$(vStartTime)’ AS StartTime,

     ‘$(vEndTime)’ AS EndTime,

      '$(vRecords)' AS Records,

       '$(vFields)' as Fields

     RESIDENT Statistics;

     STORE Statistics INTO Statistics.qvd;

     DROP TABLE Statistics;

End SUB ;

1 Solution

Accepted Solutions
felipedl
Not applicable

Re: QVD Load Stats

Hi,

Your quotation marks are strange

the first 3 lines

‘$(vTable)’ AS TableName,

     ‘$(vStartTime)’ AS StartTime,

     ‘$(vEndTime)’ AS EndTime,

Have different quotation marks as to

'$(vRecords)' AS Records,

       '$(vFields)' as Fields

Try replacing the second load with this:

LOAD

DISTINCT

     '$(vTable)' AS TableName,

     '$(vStartTime)' AS StartTime,

     '$(vEndTime)' AS EndTime,

     '$(vRecords)' AS Records,

     '$(vFields)' as Fields

RESIDENT Statistics;

Felipe

12 Replies
vishsaggi
Not applicable

Re: QVD Load Stats

What is the error you are getting can you post screen shot of that error?

its_anandrjs
Not applicable

Re: QVD Load Stats

It seems correct, remove Termination symbol after Stats and try

SUB Stats

LET vEndTime = Now();

LET vRecords = NoOfRows('$(vTable)');

LET vFields = NoOfFields('$(vTable)');

Statistics:

LOAD * From  Statistics.QVD; //where TableName <> '$(vTable)';

Join (Statistics)

LOAD

DISTINCT

     ‘$(vTable)’ AS TableName,

     ‘$(vStartTime)’ AS StartTime,

     ‘$(vEndTime)’ AS EndTime,

      '$(vRecords)' AS Records,

       '$(vFields)' as Fields

     RESIDENT Statistics;

     STORE Statistics INTO Statistics.qvd;

     DROP TABLE Statistics;

End SUB ;

felipedl
Not applicable

Re: QVD Load Stats

Hi,

Your quotation marks are strange

the first 3 lines

‘$(vTable)’ AS TableName,

     ‘$(vStartTime)’ AS StartTime,

     ‘$(vEndTime)’ AS EndTime,

Have different quotation marks as to

'$(vRecords)' AS Records,

       '$(vFields)' as Fields

Try replacing the second load with this:

LOAD

DISTINCT

     '$(vTable)' AS TableName,

     '$(vStartTime)' AS StartTime,

     '$(vEndTime)' AS EndTime,

     '$(vRecords)' AS Records,

     '$(vFields)' as Fields

RESIDENT Statistics;

Felipe

its_anandrjs
Not applicable

Re: QVD Load Stats

See the attached sample subroutine you can apply this way in your table


Fact:
Load * Inline [
KeyNames
A_Key
B_Key
C_Key
]
;

LET vTable = 'Fact';

SUB Stats
LET vEndTime = Now();
LET vRecords = NoOfRows('$(vTable)');
LET vFields = NoOfFields('$(vTable)');

Statistics:
Load * Inline
[
ColumnA
‘$(vEndTime)’
'$(vRecords)'
'$(vFields)'
]
;

STORE Statistics INTO Statistics.qvd;
//DROP TABLE Statistics;
   
End SUB;

//Calling Subroutine Here
CALL Stats

qliktech_uk
Not applicable

Re: QVD Load Stats

Thanks Anand.

qliktech_uk
Not applicable

Re: QVD Load Stats

Thanks Felipe, it worked!

qliktech_uk
Not applicable

Re: QVD Load Stats

Additional column.PNG

After I load the data, I get an additional column (column 1) which is not part of the table structure, how is it inserted and how can I delete it?

felipedl
Not applicable

Re: QVD Load Stats

I would assume its coming from this

// Probably a field in there that is loading the 1st column and as you join its perpetuated

LOAD * From  Statistics.QVD; //where TableName <> '$(vTable)';

Join (Statistics)

Just comment the above lines and you'll be good to go.

Felipe.

qliktech_uk
Not applicable

Re: QVD Load Stats

This is the script for Statistics, there is nothing else that I am adding to the table.

Statistics:

LOAD * Inline

[TableName, Source, ReloadedDate, StartTime, EndTime, Duration, Records, Fields];

Store Statistics into Statistics.QVD;

DROP Table Statistics;