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.
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

Tags (2)
1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Re: Scripting error qvds

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

29 Replies

Re: Scripting error qvds

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
Valued Contributor II

Re: Scripting error qvds

Hi,

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

Not applicable

Re: Scripting error qvds

Can you give me an example?

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

Not applicable

Re: Scripting error qvds

I am still getting

Script line error:

FOR vPeriod =  to

Gabriel
Valued Contributor II

Re: Scripting error qvds

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
Contributor III

Re: Scripting error qvds

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

Not applicable

Re: Scripting error qvds

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
Valued Contributor II

Re: Scripting error qvds

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

Re: Scripting error qvds

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

Community Browser