Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
anonymous1
Contributor III
Contributor III

For Loops

hi, 

i need to create a for loop to run through a column of my QVD (ITEM_ID) for all records that have an 'A' at the end of the ITEM_ID, then i need to copy these records to the end of the QVD table and populate the FLAG column with a '1'. so the last 2 records below would need repeated only with the FLAG column also populated. does anyone have an idea of how i go about this? 

table looks similar to:

ITEM_ID | FLAG | AMOUNT

----------------------------------

132        |                | 8

132A     |                 | 12

89A       |                  | 5

TIA

Labels (4)
1 Reply
chrismarlow
Specialist II
Specialist II

Hi,

I don't think you need anything as complicated as a loop. Try;

data:
LOAD * INLINE [
ITEM_ID , FLAG , AMOUNT
132,,8
132A,,12
89A,,5
];

load
	ITEM_ID,
	1 AS FLAG,
	AMOUNT
resident data
where right(ITEM_ID,1)='A';

Cheers,

Chris.