Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Kohli
Creator II
Creator II

Hi

In my table i have 100 records. i want show first 5 record, and last five records. what can i do for that?

3 Replies
prma7799
Master III
Master III

Please check below link it will help you to achieve your requirement

How to find top 5 and bottom 5 records in chart | Qlik Community

Anil_Babu_Samineni

We can call it as

First 10

Load * from Table;

I am not sure whether there is any direct way to fetch last 10 Records

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
kamal_sanguri
Specialist
Specialist

This way:

Create one column in script let's called it Row

    RowNo() as Row


Now you have one column which have row number for each line, Load first 5 item and Concatenate the Table with Bottom 5 items


********************Logic**************


Table:

First 5

Load *

From Table

Order By Row Asc;

Concatenate


First 5

Load *

From Table

Order By Row Asc Desc;



*************************Sample Script***************************

Data:

LOAD *,

RowNo() as Row;

Load *

Inline

[

Code11, Val11

1, 100

2, 200

3, 250

4, 150

5, 120

6, 100

7, 200

8, 180

9, 110

10, 80

11, 250

12, 220

13, 190

14, 140

15, 120

16, 130

17, 110

18, 220

19, 210

20, 190

];

NoConcatenate

NewData:

First 5

LOAD *

Resident Data

Order By Row Asc;


Concatenate

First 5

LOAD *

Resident Data

Order By Row Desc;

DROP Table Data;