Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there
I want to find the maximum number of records in a dataset. What function do I use to do this?
Regards
Rajesh Bhardwaj
Do you need this for info or do you want to re-use the value?
Recno() and rowno() might be what you want to use, otherwise if it is just for info purposes, when you go into the table viewer (CTRL+T), and hover over individual tables, it will give you the amount of rows for each table.
2 ways if you are trying to save out the value of max recs in a table to re-use elsewhere.
Either on table load you add an extra field using "rowno() as NumberOfRows" as a field and do a peek-max on this field or otherwise...
If you are trying to find maximum records in table named Table1, then you can do a resident reload such as:
Table2:
Load
max(recno()) as MaximumRecords
Resident Table1;
and then use a peek to get this value in a variable, such as
LET vMaxRecs = peek('MaximumRecords', 0, 'Table2');
Hope that helps.
Sorry, forgot to explain peek function fully.
If you use rowno() to give an incremental value of each row number, then on peek, you can use -1 as offset, as it will start at bottom of table, i.e.
if in Table1 table load you add a field such as rowno() as RowNumber,
then on peek you can do
LET vMaxRecs = peek('RowNumber', -1, 'Table1');
the -1 parameter means "start at the bottom of the given table. Using 0 (zero) means start at the top of the table.
Hope it helps.
In case you want to find the # of records in the document, you can go to Settings, Document Properties, Tables. and sort on '# Records' to get the max # of rows loaded.
Regards,
Dinesh.