ElderBrE Posted July 22, 2012 Posted July 22, 2012 Greetings, I've got a portal row which displays the time for runners in each row. Outside the portal, I have a field which calculates the Sum time of all the runners within the portal. What I have been trying to accomplish now is to have another field which makes a Sum of the top 3 times within the portal. Let's say we have 4 runners with: Runner 1 - 1 minute Runner 2 - 4 minutes Runner 3 - 1 minute Runner 4 - 1 minute Top 3 times sum: 3 minutes Does anyone know how to achieve this? Thanks
comment Posted July 22, 2012 Posted July 22, 2012 Do you need this only for display, or is this going to be used in further calculations?
ElderBrE Posted July 22, 2012 Author Posted July 22, 2012 Do you need this only for display, or is this going to be used in further calculations? Thanks for the reply, it was only to display and then to be used for sorting in a printing view. I have been able to get it done with GetLayoutObjectAttribute ( "ObjectName" ; "Content" ; 1 ; n ) which so far seems to be working beautifully, although a solution which doesn't require being in the layout would be even better in case I need to do calculations on it in the future.
comment Posted July 22, 2012 Posted July 22, 2012 (edited) it was only to display and then to be used for sorting in a printing view. Well, if it's to be used for sorting, then it's not "only to display". If you sort your relationship by Time, descending ascending, you can then sum up the three best results as = GetNthRecord ( Results::Time ; 1 ) + GetNthRecord ( Results::Time ; 2 ) + GetNthRecord ( Results::Time ; 3 ) Edited July 22, 2012 by comment
ElderBrE Posted July 22, 2012 Author Posted July 22, 2012 Well, if it's to be used for sorting, then it's not "only to display". If you sort your relationship by Time, descending, you can then sum up the three best results as = GetNthRecord ( Results::Time ; 1 ) + GetNthRecord ( Results::Time ; 2 ) + GetNthRecord ( Results::Time ; 3 ) Sorry, didn't consider sorting as a calculation, my mistake. Tried that option, but for some reason it would only sort by creation date and spent quite some time trying to get it to work that way, but upon reading the documentation it explained it could only do it that way and I gave up that method. Edit: Thinking about it, maybe I was sorting incorrectly? I tried sorting both the current table and the related table, is there another way to sort a relationship through the relationships window or something like that?
eos Posted July 22, 2012 Posted July 22, 2012 If you sort your relationship by Time, descending, you can then sum up the three best results as = GetNthRecord ( Results::Time ; 1 ) + GetNthRecord ( Results::Time ; 2 ) + GetNthRecord ( Results::Time ; 3 ) Shouldn't it be ascending, since greater time = worse result?
comment Posted July 22, 2012 Posted July 22, 2012 Sorry, didn't consider sorting as a calculation, my mistake. Well, it's not exactly a calculation either. I guess the mistake was mine for not allowing a wider margin for "things that are not display". Tried that option, but for some reason it would only sort by creation date Not sure what you mean by that: you need to set the sort order of the result records in the definition of the relationship. Shouldn't it be ascending, since greater time = worse result? Right. Thanks for the catch.
ElderBrE Posted July 22, 2012 Author Posted July 22, 2012 Not sure what you mean by that: you need to set the sort order of the result records in the definition of the relationship. Had never used this part when defining a relationship, had to look around for it but this works great now, thanks for the help!
Recommended Posts
This topic is 4564 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 accountSign in
Already have an account? Sign in here.
Sign In Now