Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

Get range of values from sequence

Hi all,

I have following data:

Name, ID

A,1

A,2

A,3

A,4

A,5

B,6

B,7

B,8

B,9

A,98

A,99

B,101

B,121

I want to make it as a range:

O/P:

Name  Start  End

A            1     5

B            6     9

A            98   99

B            101  121

Any help is highly appreciated

1 Solution

Accepted Solutions
sunny_talwar

May be try this:

Region:

LOAD *,

  If(Previous(Name) = Name, Alt(Peek('Key'), 1), RangeSum(Peek('Key'), 1)) as Key;

LOAD * Inline

[

Name, ID

A,1

A,2

A,3

A,4

A,5

B,6

B,7

B,8

B,9

A,98

A,99

B,101

B,121

];

TempRegion:

LOAD Name,

  Key,

  Min(ID) as Start,

  Max(ID) as End

Resident Region

Group By Name, Key;

DROP Table Region;


Capture.PNG

View solution in original post

20 Replies
Not applicable

FOLOW

markgraham123
Specialist
Specialist
Author

Hi,

I just updated the post.

Min Max doesn't work in my scenario.

Not applicable

More details?

markgraham123
Specialist
Specialist
Author

@rodrigo,

Please see the updated post and attachment.

Not applicable

what is the paramether for range?

markgraham123
Specialist
Specialist
Author

The IDs doesn't have specific start and end point. So, Min and MAX Doesn't work.

they might come in between the numbers.

Not applicable

that I understand. But as you need to separate, you do not have a specific parameter? 10 to 10

markgraham123
Specialist
Specialist
Author

Sorry Sir.

I was not able to understand.

For every range of numbers for 'Name',

I want to display its starting and Ending number.

Not applicable

if the names are different the min and max functions. In your example does not work for that one name has several ranges.