GC GYM Posted November 2, 2008 Posted November 2, 2008 Hi All, I have a table of students. To group those from the same family I use a self-join relationship based on surname & home phone and display them in a portal. Both the relationship and the portal are sorted by student contact hours, descending. I need to calculate a family discount rate so that if the student falls into the top row of the portal, they calc as 1, otherwise as 0.9 Since there seems to be no First() function, I changed the relationship & portal sorts to descending and used If( Last(MyFamilyMembers::NameFull) = NameFull; 1;.9 ) My flawed logic: "If I am at the person at the bottom of the list, give me a 1, otherwise give me a 0.9" All family members end up with a "1" . Any suggestions
comment Posted November 2, 2008 Posted November 2, 2008 From what context is this calculation defined?
comment Posted November 2, 2008 Posted November 2, 2008 I meant: from which occurrence of the Students table?
GC GYM Posted November 2, 2008 Author Posted November 2, 2008 The same occurrence as the layout containing the portal. Attached are some screen shots in case that makes it clearer. Read 'Gymnasts' as 'Students'. Thanks, Phil Studentfamily.zip
David Jondreau Posted November 2, 2008 Posted November 2, 2008 I need to calculate a family discount rate so that if the student falls into the top row of the portal, they calc as 1, otherwise as 0.9 Since there seems to be no First() function, I changed the relationship & portal sorts to descending and used If( Last(MyFamilyMembers::NameFull) = NameFull; 1;.9 ) My flawed logic: "If I am at the person at the bottom of the list, give me a 1, otherwise give me a 0.9" All family members end up with a "1" . It's a work around for something that actually has an easy answer. You're right, there is no First() function. But if you simply reference the field itself, the "top row of the portal" is returned (assuming the portal is sorted the same way as the relationship, or not at all). The First() function for related reocrds is to simply not use a function at all.
GC GYM Posted November 2, 2008 Author Posted November 2, 2008 OK so I tried this; If( MyFamilyMembers::NameFull = NameFull; 1;.9 ) But the calc. still returns a "1" for everyone.
comment Posted November 2, 2008 Posted November 2, 2008 Perhaps you should post your file (just the 2 TO's with some sample data would be enough).
GC GYM Posted November 2, 2008 Author Posted November 2, 2008 That would be great if you could have a look. It was a huge file so it's taken a while to empty it. Use acct name: ph password:1234 The calc field is the last one in the Gymnasts Table 'Family Rank' The family members portal is on the layout 'GymnastDetail' Many thanks, Phil Gym.fp7.zip
comment Posted November 2, 2008 Posted November 2, 2008 The calculation returns the correct result. However, the field is formatted to display as decimal with 0 decimal digits - which makes a result of 0.9 APPEAR as 1.
GC GYM Posted November 2, 2008 Author Posted November 2, 2008 AAAAAHHHHHHHH!! Thank you everybody! The answer is always hiding in there somewhere! Regards, Phil
Recommended Posts
This topic is 5934 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