Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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_NO | VERSION | LAST_VERSION_FLAG |
2013026 | 1 | No |
2013026 | 2 | No |
2013026 | 3 | No |
2013026 | 4 | Yes |
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
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
Hey Chris
Sorry if i was not clear enough ^^
My Actual situation is the following:
FOLLOWUP_NO | VERSION |
2013026 | 1 |
2013026 | 2 |
2013026 | 3 |
2013026 | 4 |
and my desired output is the following:
FOLLOWUP_NO | VERSION | LAST_VERSION_FLAG |
2013026 | 1 | No |
2013026 | 2 | No |
2013026 | 3 | No |
2013026 | 4 | Yes |
So LAST_VERSION_FLAG should be calculated in script.
Hope i made it clear now.
Best Regards,
Juan Pedro
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
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;
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