Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nth Largest 1

Status
Not open for further replies.

misterjib

Technical User
Nov 7, 2006
8
GB
I'm probably (being) a bit stupid - any help is sincerely welcome.

All i want to display is a single record in my report header /footer depending on Nth Largest. I've summarised the Nth most recent date and i cant for the life of me work out how to display values from other fields in the same recordset...
 
You could use a formulal like the following in the detail section:

whileprintingrecords;
currencyvar x;
stringvar y;
numbervar z;
if {table.date} = nthlargest(1,{table.date}) then
(
x := {table.currency};
y := {table.string};
z := {table.number};
);

Then use a display formula in the report footer:
whileprintingrecords;
currencyvar x;
stringvar y;
numbervar z;
totext(z,0,"")+ ": "+totext(x,2)+ " "+y

Or, if you sorted by the date field, and the other fields in descending order, the display formula would also work in the page header. You could then suppress it with a formula like:

pagenumber > 1

-LB
 
This is brilliant lbass, really appreciate your assistance, but i'm still having difficulty displaying. can i just say, i'm a graphic person not a programmer...

ok so: detail section

whileprintingrecords;
numbervar INR;
if {Reviews.Date} = nthlargest(2,{Reviews.Date}) then
(
INR := {Reviews.INR Today};
);

gives me the 2nd most recent INR but when i try to display in the header/footer i can only seem to pick up the nthlargest(1.... so i tried this

whileprintingrecords;
numbervar INR;
if {Reviews.Date} = nthlargest(2,{Reviews.Date}) then
(
INR := {Reviews.INR Today};
);
totext(INR,1,"")

clearly i dont know what i'm doing!
 
Forgive me lbass - your solution works fine in the footer.

many many thanks
 
Nthlargest(2), will only work in the report footer. Your first formula belongs in the detail section, and then in the report footer, use:

whileprintingrecords;
numbervar INR;

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top