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: 
vikasshana
Creator II
Creator II

Copy the value into next rows

 

Hi,

I've the below data in my app.

ID Number
1 264569
1 264896789563
1 647896321456
1 456789123456
1 234567896542
2 756324
2 596478963215
2 236974596321

 

And using the below load script to create two new columns like below

Load ID,
Number,
if(Len(Number)=6, Number) as Number1
if(Len(Number)>6, Number) as Number2

I received below output.

ID Number Number1 Number2
1 264569 264569  
1 264896789563   264896789563
1 647896321456   647896321456
1 456789123456   456789123456
1 234567896542   234567896542
2 756324 756324  
2 596478963215   596478963215
2 236974596321   236974596321

 

But I'm looking for below output

ID Number Number1 Number2
1 264896789563 264569 264896789563
1 647896321456 264569 647896321456
1 456789123456 264569 456789123456
1 234567896542 264569 234567896542
2 596478963215 756324 596478963215
2 236974596321 756324 236974596321

 

@tresesco 

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try like:

t1:
Load * Inline [
ID, Number
1, 264569
1, 264896789563
1, 647896321456
1, 456789123456
1, 234567896542
2, 756324
2, 596478963215
2, 236974596321];

NoConcatenate
t2:
Load ID,
Number as Number1 Resident t1 Where len(Number)=6;
Join
Load ID,
Number as Number2 Resident t1 Where Len(Number)>6;

DROP Table t1;

View solution in original post

4 Replies
brunobertels
Master
Master

hi 

may be this 

if(Len(Number)=6, Number, peek(Number1)) as Number1
if(Len(Number)>6, Number, peek(Number2)) as Number2

vikasshana
Creator II
Creator II
Author

I tried it but still the same

vikasshana_0-1662708494098.png

 

tresesco
MVP
MVP

Try like:

t1:
Load * Inline [
ID, Number
1, 264569
1, 264896789563
1, 647896321456
1, 456789123456
1, 234567896542
2, 756324
2, 596478963215
2, 236974596321];

NoConcatenate
t2:
Load ID,
Number as Number1 Resident t1 Where len(Number)=6;
Join
Load ID,
Number as Number2 Resident t1 Where Len(Number)>6;

DROP Table t1;

vikasshana
Creator II
Creator II
Author

Thanks @tresesco it is working now.