Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Version's Flag in Load Script

Hey everyone,

i need to make a flag that determinates if a line is the last one for a item and i would like to do it in load script.

The LAST_VERSION_FLAG is the field i need to create. Any advice appreciated.

Cheers

Juan Pedro

FOLLOWUP_NOVERSIONLAST_VERSION_FLAG
20130261No
20130262No
20130263No
20130264Yes
1 Solution

Accepted Solutions
Not applicable

Re: Version's Flag in Load Script

OK, understood

Tmp:

LOAD Folllwoup_no, max(version) as max  from Table group by Folllwoup_no;

LET vflag = peek('tmp', 0, 'max');

T1:

LOAD followup_no,

version,

if(version = $(vFlag), 'Yes,' No')  as flag_version

resident Original_table;

drop table Original_table;

Here is a solution. It is not the only one, you can use applymap, or use 2 tables with join

up to you

best rregards

Chris

5 Replies
Not applicable

Re: Version's Flag in Load Script

Hi Juan

I don't really undrstand the question as it seems you got already the answer.

Load your table and get the Version WHERE Flag='Yes'

EX :

LET vFlag = peek('table_name', 0, 'version');

Display $(vFlag) in a text object for example

best regards

Chris

Not applicable

Re: Version's Flag in Load Script

Hey Chris

Sorry if i was not clear enough ^^

My Actual situation is the following:

FOLLOWUP_NOVERSION
20130261
20130262
20130263
20130264

and my desired output is the following:

FOLLOWUP_NOVERSIONLAST_VERSION_FLAG
20130261No
20130262No
20130263No
20130264Yes

So LAST_VERSION_FLAG should be calculated in script.

Hope i made it clear now.

Best Regards,

Juan Pedro

Not applicable

Re: Version's Flag in Load Script

OK, understood

Tmp:

LOAD Folllwoup_no, max(version) as max  from Table group by Folllwoup_no;

LET vflag = peek('tmp', 0, 'max');

T1:

LOAD followup_no,

version,

if(version = $(vFlag), 'Yes,' No')  as flag_version

resident Original_table;

drop table Original_table;

Here is a solution. It is not the only one, you can use applymap, or use 2 tables with join

up to you

best rregards

Chris

Re: Version's Flag in Load Script

Hi

Try like this

Test1:

LOAD * Inline

[

FOLLOWUP_NO,VERSION

2013026,1

2013026,2

2013026,3

2013026,4

];

Left Join(Test1)

Load FOLLOWUP_NO, Max(VERSION) AS Flag Resident Test1 Group by FOLLOWUP_NO;

Test:

Load FOLLOWUP_NO, VERSION, if(Flag = VERSION, 1, 0) AS LAST_VERSION_FLAG Resident Test1;

DROP Table Test1;

Not applicable

Re: Version's Flag in Load Script

Thank you both,

1 year and a half of QV develpment and i never used a Group By in the Load Script. Epic ^^

Cheers,

Juan Pedro

Community Browser