July 24, 200619 yr Here is a puzzle. I'm trying to convert answers like 1, 2, 3 etc into grades like A,B,C etc. I have a field called gAnswer which contains answers separated by a carriage return: 3 5 2 1 4 5 etc. If I use the middle values functions as follows: MiddleValues (ImportData::gAnswer ; 2 ; 1 ) it calculates to the 2nd value in the field ie) 5 But when I try to set another field to the converted value with this statement I get "F" every time: Case(MiddleValues ( ImportData::gAnswer ; 2 ; 1 )=1;"A"; MiddleValues ( ImportData::gAnswer ; 2 ; 1 )=2;"B"; MiddleValues ( ImportData::gAnswer ; 2 ; 1 )=3;"C"; MiddleValues ( ImportData::gAnswer ; 2 ; 1 )=4;"D"; MiddleValues ( ImportData::gAnswer ; 2 ; 1 )=5;"E"; "F") This has me confused. Any ideas?
July 24, 200619 yr try Case ( gAnswer = 1; "A"; gAnswer =2;"B"; gAnswer =3;"C"; gAnswer =4;"D"; gAnswer =5; "E"; "F") HTH Lee
July 24, 200619 yr Author Thanks but that doesn't work because gAnswer is not equal to 1 or 2 or 3 or 4 or 5. gAnswer contains: 3 5 2 1 4 5 all separated by carriage returns. In other words gAnswer contains all of the answers for a test. I'm trying to extract the various values individually with the MiddleValue function and although the MiddleValue function does calculate to 5 or 2 or 1 or 4 etc. depending on the parameters, I can't seem to get it to stick when I use the Case statement?
July 24, 200619 yr MiddleValues() returns the value followed by a carriage return. That's why none of your tests returns true. In version 8, you can use the GetValue() function instead. BTW, it seems Choose() could be more efficient here than Case().
Create an account or sign in to comment