Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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

View solution in original post

5 Replies
Not applicable
Author

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
Author

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
Author

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

MayilVahanan

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;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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