Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Scripting error qvds

Hi

I have been struggling for a while with qvd's

I am receiving this error when running this code, what am I missing here.

I am using the Text function to try to change the data type as I was getting qvd's created for 201413, 201414 etc, I only want a file for every actual Period which runs from 2003 - 01 through 12, then 2014-01 to 12

Script line error:

FOR vPeriod =  to

Noconcatenate TempPeriod:

LOAD distinct Text(HPeriod) as Period

Resident HISTORYAGEING

order by HPeriod;

Noconcatenate TempMinMax:

LOAD FirstValue(HPeriod) as MinPeriod,

LastValue(HPeriod) as MaxPeriod

Resident HISTORYAGEING;

LET vPeriodMin = Peek(MinPeriod);

LET vPeriodMax = Peek(MaxPeriod);

FOR vPeriod = $(vPeriodMin) to $(vPeriodMax)

NoConcatenate

TempData:

LOAD * Resident HISTORYAGEING where HPeriod = $(vPeriod);

STORE TempData into HISTORYAGEING_$(vPeriod).qvd;

Drop table TempData;

NEXT

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Attached is a working example.  I had to add back one noconcatenate after all.

View solution in original post

29 Replies
sunny_talwar

May be your MinPeriod and MaxPeriod are not numeric values. Try may be this:

Noconcatenate TempMinMax:

LOAD Num(FirstValue(HPeriod)) as MinPeriod,

          Num(LastValue(HPeriod)) as MaxPeriod

Resident HISTORYAGEING;

LET vPeriodMin = Peek(MinPeriod);

LET vPeriodMax = Peek(MaxPeriod);

FOR vPeriod = $(vPeriodMin) to $(vPeriodMax)

NoConcatenate

TempData:

LOAD * Resident HISTORYAGEING where HPeriod = $(vPeriod);

STORE TempData into HISTORYAGEING_$(vPeriod).qvd;

Drop table TempData;

NEXT

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

I think the logic need to be different here. I will look to use FOR EACH Loop

Not applicable
Author

Can you give me an example?

On Thu, May 7, 2015 at 11:03 AM, Gabriel Oluwaseye <qcwebmaster@qlikview.com

Not applicable
Author

I am still getting

Script line error:

FOR vPeriod =  to

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Are you using calendar script to build this?

My reason for asking is, you can still use For Loop.

You just have to have a Data Island of all the dates between Min and Max of your date, then use For Loop.


vincent_ardiet
Specialist
Specialist

Try with quotes in your peek expression like this : LET vPeriodMin = Peek('MinPeriod');

Not applicable
Author

I built up a table from a resident load from the original table. Note

though the field is a Financialperiod, so 201501, 201502 etc. There are no

other date fields in use in this table

On Thu, May 7, 2015 at 5:14 PM, Gabriel Oluwaseye <qcwebmaster@qlikview.com>

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Please try to understand the script below and implement it.

I have tried to include notes where I feel clarification is needed.

LET vMin = FLoor(MakeDate(2015,04,20));

LET vMax = FLoor(MakeDate(2015,04,30));

LET vDiff = vMax - vMin + 1; // Plus 1 here ensure we have to full range of date differerence

DateIsland:
LOAD
$(vMin) + RecNo() -1 AS Date   //Minus 1 here ensures that the date starts from the vMin date in our loop
AutoGenerate ($(vDiff));
//Load full date range
FOR i = 0 TO NoOfRows('DateIsland')
LET vQVDDate = Date(Peek('Date',$(i),'DateIsland'),'YYYY-MM-DD');
TRACE $(vQVDDate);
//Here include your store procedure scripts
NEXT i;

Not applicable
Author

Thanks Gabriel

I think I understand what your script does, the concern I have is still

that I do not have full dates, I only have one date field which is not a

fulldate, the field comes through from the database as YYYYMM, that is all

I have. This originally created the issue that I had that it created files

for non existant months, like month 13, 14, because it was a numeric, so

when it got to December 2014 it would create a 201413 after December and

just carried on with the months. The date range one you gave is really

going to help with later scripting on other models, but for this one with

only Financial periods, I am just not getting it

I have changed the script to a for each loop. It now creates files, but

only for the last month

Noconcatenate TempPeriod:

LOAD HPeriod as Period

Resident HISTORYAGEING

order by HPeriod;

for each Period in TempPeriod

NoConcatenate

TempData:

LOAD * Resident HISTORYAGEING where HPeriod = $(vPeriod);

;

STORE TempData INTO HISTORYAGEING_$(vPeriod).qvd (qvd);

DROP TABLE TempData;

next

On Fri, May 8, 2015 at 12:23 PM, Gabriel Oluwaseye <qcwebmaster@qlikview.com