Newbies themus Posted April 1, 2007 Newbies Posted April 1, 2007 I have many grade fields that all require a calculation to get the subject grade transformed into a number so they can be averaged for the different semesters. The calculation I am using is: Position("FDCBA"; Left(fieldLet1; 1); 1; 1) - 1 + Choose(Position("+-"; Right(fieldLet1; 1); 1; 1); 0; .33; -.33). This works fine but I don't want to duplicate it for each subject. Is there a way to write it once (maybe as a custom function) and use it for all the subject grades?
The Shadow Posted April 1, 2007 Posted April 1, 2007 Sure, you just define it as a custom function with a name, like ConvertGradeLetter, with a parameter of gradeLetter: ConvertGradeLetter( gradeLetter ) = Position("FDCBA"; Left(gradeLetter; 1); 1; 1) - 1 + Choose(Position("+-"; Right(gradeLetter; 1); 1; 1); 0; .33; -.33)
Newbies themus Posted April 1, 2007 Author Newbies Posted April 1, 2007 What am I missing? Doesn't any calculation that has a reference GradeLetter always need a particular field called GradeLetter? I have many different fields with letter grades.
Raybaudi Posted April 1, 2007 Posted April 1, 2007 So is better ? /* ConvertToGradeLetter ( text ) custom function */ Position("FDCBA"; Left(text; 1); 1; 1) - 1 + Choose(Position("+-"; Right(text; 1); 1; 1); 0; .33; -.33)
comment Posted April 2, 2007 Posted April 2, 2007 What am I missing? ... I have many different fields with letter grades. You should have ONE field, with one calculation - but many (related) records.
The Shadow Posted April 2, 2007 Posted April 2, 2007 gradeLetter is a parameter to the custom function, when you use the custom function, you pass in the field you want it computed for as the argument - that's how the custom functions let you reuse the calculation in multiple places.
comment Posted April 2, 2007 Posted April 2, 2007 I just noticed the title of this thread. A calculation with no reference returns a constant (unless it incorporates one of the Get() functions, e.g. current date). Since your result is a function of input, the input needs to referenced. If you have 20 input fields (letter grades), you will need 20 calculation fields, each referencing its own input field. It doesn't matter if you use a custom function or not. A custom function would merely shorten the formula. The real problem here is the data structure. You could use a repeating field for the grades, and a repeating calculation field for the translation, but that would be only a partial solution.
Recommended Posts
This topic is 6506 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