Nested IIf experssion

G

Guest

I need to convert a letter grade in my database to the GPA equivalent. I was
able to get the expression to work for one variable:

GPA: IIf([GR]="A",4,0)

Now I need to add the rest of the grades and number grade equivalent, but do
not know how to nest the IIf expression.

Thank you,
 
F

fredg

I need to convert a letter grade in my database to the GPA equivalent. I was
able to get the expression to work for one variable:

GPA: IIf([GR]="A",4,0)

Now I need to add the rest of the grades and number grade equivalent, but do
not know how to nest the IIf expression.

Thank you,

GPA: IIf([GR]="A",4,IIf([GR] = "B",3,IIf([GR] =
"C",2,IIf([GR]="D",1,0))))
 
G

Guest

You can also use the switch function

GPA: Switch([GR]="A",4,[GR]="B",3,[GR]="C",2,[GR]="D",1)
 
M

Marshall Barton

Jacqueline said:
I need to convert a letter grade in my database to the GPA equivalent. I was
able to get the expression to work for one variable:

GPA: IIf([GR]="A",4,0)

Now I need to add the rest of the grades and number grade equivalent, but do
not know how to nest the IIf expression.


The IIf will get very messy. Try this instead:

Switch(Gr="A",4, Gr="B',3, Gr,="C",2, Gr="D",1, True,0)
 
D

Douglas J. Steele

Personally, I think a better alternative would be to build a table that has
two columns (the letter grade and the mark equivalent), and join that table
to your existing table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top