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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to make table convert from range to sequence?

Hi,

I want to conert table from

useridbeginend
A1015


to

useriddata
A10
A11
A12
A13
A14
A15


Which funciion can I use? intervalmatch or another?

Thanks:)

1 Solution

Accepted Solutions
Not applicable
Author

Hello,

I would load them within a for..next similar to the exam below:

Sequence:
LOAD * Inline [
userid,begin,end
A,10,15
B,12,23
C,11,17
];

FOR vZeile=0 to fieldvaluecount( 'userid' )-1
LET vUserid= peek( 'userid' , $(vZeile) ,'Sequence');
LET vStart= peek( 'begin' , $(vZeile) ,'Sequence');
LET vEnd= peek( 'end' , $(vZeile) ,'Sequence');
// TRACE Zeile $(vZeile): $(vUserid) from $(vStart) to $(vEnd) ;

Tabl:
LOAD
'$(vUserid)' AS User,
$(vStart) + RecNo()-1 AS Value
AutoGenerate($(vEnd) - $(vStart) +1);

NEXT vZeile;


NOTES:

Had two timeconsuming issues:

First I didn't put the tablename of the peek() into single-quotes. Without quotes it works fine until using a Load()-statement within the for..next. It took me two hours of wasted time until I remembered a thread with a similar topic....

Next was that I used the rowno(). This is normally my favorite, but in this case recno() is the one.

HtH

Roland

View solution in original post

3 Replies
Not applicable
Author

Hello,

I would load them within a for..next similar to the exam below:

Sequence:
LOAD * Inline [
userid,begin,end
A,10,15
B,12,23
C,11,17
];

FOR vZeile=0 to fieldvaluecount( 'userid' )-1
LET vUserid= peek( 'userid' , $(vZeile) ,'Sequence');
LET vStart= peek( 'begin' , $(vZeile) ,'Sequence');
LET vEnd= peek( 'end' , $(vZeile) ,'Sequence');
// TRACE Zeile $(vZeile): $(vUserid) from $(vStart) to $(vEnd) ;

Tabl:
LOAD
'$(vUserid)' AS User,
$(vStart) + RecNo()-1 AS Value
AutoGenerate($(vEnd) - $(vStart) +1);

NEXT vZeile;


NOTES:

Had two timeconsuming issues:

First I didn't put the tablename of the peek() into single-quotes. Without quotes it works fine until using a Load()-statement within the for..next. It took me two hours of wasted time until I remembered a thread with a similar topic....

Next was that I used the rowno(). This is normally my favorite, but in this case recno() is the one.

HtH

Roland

Not applicable
Author

Hi Roland,

Thank you for your reply. It's a good idea and the code works well.

I have another code, please give me some advice Big Smile

Sequence:
LOAD * Inline [
userid,begin,end
A,10,15
B,12,23
C,11,17
];

n:
Load recno() as data AutoGenerate 100;

t:
intervalmatch(data) load begin,end resident Sequence;
join load * resident Sequence;
drop table Sequence;
drop table n;
drop field begin;
drop field end;


Zhou Dazhao

Not applicable
Author

Hello Zhou,

yes, nice idea. There are often different ways to solve a problem efficient.

See you for next discussion!

Roland