Intro. expressions in calculated fields

  • Thread starter Thread starter Mark Houghton
  • Start date Start date
M

Mark Houghton

I have (to simplify somewhat) four fields in my query:
name (text)
V (number)
A (number)
K (number)

(it's not important, but V, A, and K are learning styles, and the fields
contain diagnostic test scores in each of these areas).

I want to calculate a field to contain "V" if V is the biggest of the three,
"A" if A is the biggest, etc. I know there's the added complication if any
are the same, but I'll start easy.

If only there were only two, then I could use
=Iif([V]>[A],"V","A")
I think. Seems to work.

But I need more conditions than this. Is there any way of using "multi line"
expressions?

TIA.
M.
 
you would need to nest your statements....

=Iif (condition, true, Iif (condition, true, false))


Rick B

message I have (to simplify somewhat) four fields in my query:
name (text)
V (number)
A (number)
K (number)

(it's not important, but V, A, and K are learning styles, and the fields
contain diagnostic test scores in each of these areas).

I want to calculate a field to contain "V" if V is the biggest of the three,
"A" if A is the biggest, etc. I know there's the added complication if any
are the same, but I'll start easy.

If only there were only two, then I could use
=Iif([V]>[A],"V","A")
I think. Seems to work.

But I need more conditions than this. Is there any way of using "multi line"
expressions?

TIA.
M.
 
Mark Houghton said:
I have (to simplify somewhat) four fields in my query:
name (text)
V (number)
A (number)
K (number)

(it's not important, but V, A, and K are learning styles, and the fields
contain diagnostic test scores in each of these areas).

I want to calculate a field to contain "V" if V is the biggest of the three,
"A" if A is the biggest, etc. I know there's the added complication if any
are the same, but I'll start easy.

If only there were only two, then I could use
=Iif([V]>[A],"V","A")
I think. Seems to work.

But I need more conditions than this. Is there any way of using "multi line"
expressions?

You can nest IIf()s (they just get hard to read)

=IIf([V]>[A], IIf([V]>[K], "V", "K"), IIf([A]>[K], [A], [K]))

If I have to nest more that a couple layers deep I write a custom function
instead.
 
Back
Top