Jump to content

This topic is 7989 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hey there,

If I wanted to find the highest value within a relationship I'd use

max(relationship::field)

How do I find the 2nd highest value?

Thanks,

Dan

Posted

Omit the highest valued records and use the Max() function again? Just guessing here...

Posted

Hi,

Category field

Price

MaxPrice by category = Max(selfjoinOnCategory::Price)

Intermediate Calc = Case(Price < MaxPrice by category,Price, 0)

MaxSecondHighest Price = Max(SelfjoinOnCategory::Intermediate Calc)

Intermediate2 = Case(Price<MaxSecondHighest Price, Price,0)

MaxThirdHighest Price = Max(SelfjoinOnCategory::Intermediate2)

...

Posted

Thanks everyone,

These are great ideas. Ugo's solution does the trick and avoids using a script, so I'm declaring it the winner. ;-)

I hope I can get to the point where I'm answering half as many questions as I'm asking.

Cheers,

Dan

Posted

Hi Dan,

Actually, after re-reading all the answers, I think Vaughan had it the same way .

Omit the highest valued records and use the Max() function again? Just guessing here...

Just guessing here ?

I want to have Vaughan kids!!! grin.gif

Posted

Oh yeah, I guess so. Thanks, Vaughn. It makes more sense now that I've walked through it.

Unfortunately, after I got it up and running, I realized that that wasn't quite what I was after. It's more subtle than that, and I'm not sure I can even really describe the problem. I'm still working on wrapping my head around it.

But thanks for the help. Always good to learn a new technique.

Dan

Posted

Ugo wrote: "I want to have Vaughan kids!!!"

ROTFLMAO!

Posted

Hey Guys,

Now that everyone has ROTF and LTAs off, I figured out what my real question was. (Must be all that laughing relieved some stress and helped me to clarify my thought process.) :-)

I didn't just want to find the second highest value in a relationship, but the highest value in a relationship that is less than the current value.

For example...

A 1

B 2

C 3

D 4

E 5

So for record B, the highest value that is less than B's value (i.e., 2) is 1. For record C it is 2. For record D it is 3, and so forth.

Any thoughts on how to find this one? I'm thinking that I'll have to rely on a script for this. Yet in the back of my head I still think I can do it with a calculation. But my logic centers must be out of whack, 'cause I can't get this.

Thanks,

Dan

Posted

Hi Dan,

Scripted method I think.

Set fied g_record_ID (record_ID)

Go to related record (show all)

Sort on your number field descending

Loop

Go to next record

End Loop when Record_ID = g_record_ID

Go to previous record

Omit

Show omitted.

Posted

Thanks Ugo,

I've gone with the script method. The actual situation was quite a bit more complex than I described, so the script got pretty convoluted. But your's was a good starting point. It seems cumbersome -- at least it was to write -- but it works and it seems pretty quick. We'll see once I get the db full of data.

Cheers,

Dan

Posted

Hi Dan,

This scripting method would lead you to another layout, isolating (omitting...) one record...Not really dynamic....

Depending on your file structure and interface needs, you should take a look at "fixed portals" at http://www.fmfiles.com or even DJ's renumbering portal in the sample section.

Scripting the find using these solutions, would offer you a cleaner way to view at the fly within the current layout (you surely have some room left) the record you are looking for, even highlightting it.

This topic is 7989 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.