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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
shumailh
Creator III
Creator III

How to select Last 30 Records?

I tried Set Analysis \ use peek function but in the i couldn't found the proper solution to select last 30 records. Can anybody help me out?

Shumail

9 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Shumail

Can you do the determination of the last 30 in the load script?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
shumailh
Creator III
Creator III
Author

I can try... not sure either it will surve the purpose or not.

I know there is a clause first but last is not there.


First 10 Load * from abc.csv;


Regards,
Shumail Hussain

suniljain
Master
Master

Select first 30 record and order data in descending order.

shumailh
Creator III
Creator III
Author

For the date field I am using the below expression but for others I think I can try Sunil's Suggestion.



=if(year(MnYr)=2010 or month(MnYr)=month(today()-30),(Sum(Count)))
<pre>
Regards,
Shumail Hussain</body>
shumailh
Creator III
Creator III
Author

If this is the ways then, How would i modify the below code to first sort it by loadOrder and then select first 30

RBG_Fin_Grid:
CrossTable(RBG_Fin_MnYr, RBG_Fin_Amount)
LOAD
[RB] as Fin_Category, EOP, [NII],
[FEE_INC], [OI], [FEE_OI]
FROM [$(abc)\Jul-10\PD_Jul2010.xlsx]
(ooxml, embedded labels, header is 2 lines, table is [2008], filters(
Remove(Row, RowCnd(Interval, Pos(Top, 7), Pos(Top, 96), Select(1, 0))),
Transpose()
));

Like below????

RBG_Fin_Grid:
First 30 CrossTable(RBG_Fin_MnYr, RBG_Fin_Amount)
LOAD
[RB] as Fin_Category, EOP, [NII],
[FEE_INC], [OI], [FEE_OI]
FROM [$(abc)\Jul-10\PD_Jul2010.xlsx]
(ooxml, embedded labels, header is 2 lines, table is [2008], filters(
Remove(Row, RowCnd(Interval, Pos(Top, 7), Pos(Top, 96), Select(1, 0))),
Transpose()
)) Order by LoadOrder desc;

donot know how can i order my data by loadorder desc

Shumail

jonathandienst
Partner - Champion III
Partner - Champion III

Shumail

AFAIK it is not possible to do LoadOrder desc. I can suggest two alternatives

  1. Load without a sort qualifier, and see if the load order corresponds to sorting by one or more of the fields. Then sort desc by that/those field(s).
  2. Do the load in two passes - first load into a temp table with count field using RowNo() AS RowCount. Then load the last 30 rows from the temp table into the final table.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
llauses243
Creator III
Creator III

try ...

models:First 10 Load * from abc.csv;

llauses243
Creator III
Creator III

sorry ... this is propose for Last 3 records...





Load

LOAD * INLINE [

Year,Indicator_Name,Values

2000,IndicA,50

2001,IndicA,60

2002,IndicA,70

2000,IndicB,50

2001,IndicB,60

2002,IndicB,70

2000,IndicC,50

2001,IndicC,60

2002,IndicC,70

];



qualify

last:

First

/Luis 3 Load * Resident T1 order by altnumber; *;*, Autonumber(Indicator_Name) as Indicator_Key, 100000000 - RowNo() as altnumber; //artificio

llauses243
Creator III
Creator III

[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/1754.solution.txt:550:0]

sorry ... here clear in .txt attach ...