Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Duplicating records

Hi,

I have the following table inputed:

IDNamePlaceNumber of recordsdateAmount
111QWEUSA301/05, 02/05, 03/0524
222RQWUK109/0957
333GFDFRA108/0723
444FGGKWD104/02178
555MJHGER206/08, 24/0934
666FFDITA107/0423

I need to dulplicate certain rows depending on what the "number of records" column says and also split the dates so that there is only 1 in each field.

The end table I expect to see is the following:

IDNamePlaceNumber of Recordsdateamount
111-1QWEUSA101/0524
111-2QWEUSA102/0524
111-3QWEUSA103/0524
222RQWUK109/0957
333GFDFRA108/0723
444FGGKWD104/02178
555-1MJHGER106/0834
555-2MJHGER124/0934
666FFDITA107/0423

Is it possible to do this in QlikView?

thanks!

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try this:

load ID & '-' & autonumber(recno(),ID) as ID, Name, Place,[Number of Records], date, amount;

load ID, Name, Place, 1 as [Number of Records], subfield(date,',') as date, amount

from ...somewhere...;


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Yes, you use the subfield function for that.

load ID, Name, Place, 1 as [Number of Records], subfield(date,',') as date, amount

from ...somewhere...;

The subfield function will create a record for every value in the comma separated list in the date field.


talk is cheap, supply exceeds demand
Not applicable
Author

that is almost perfect thanks!

one question though:

I need the ID field to be unique, how can I do this?

i.e. I want to go from

111

111

111

TO

111-1

111-2

111-3

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try this:

load ID & '-' & autonumber(recno(),ID) as ID, Name, Place,[Number of Records], date, amount;

load ID, Name, Place, 1 as [Number of Records], subfield(date,',') as date, amount

from ...somewhere...;


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks! thats a big help

hic
Former Employee
Former Employee

A while loop is cleaner:

Load *,

     Subfield(date,',',IterNo()) as Separate Date

     From ...

     While IterNo() <= [Number of records];

HIC