help on calculations

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to make a calculation in a field on a query as follows

when [position] is less then 21 and greater then 0 = A
when [position is less then 41 and greater then 20 = B
when [position is less then 51 and greater then 40 = C

I am not sure exactly how to write that formula?
I appreciate your help.
 
I would use the Switch function

Switch(Position>0 and Position <21, "A",Position>20 and Position <41,
"B",Position>40 and Position <51, "C")

Of course with regular ranges like that you could also use choose in
combination with an immediate if.

IIF(Position>0,Choose(Position\20 +1,"A","B","C"),Null)
 
I am trying to make a calculation in a field on a query as follows

when [position] is less then 21 and greater then 0 = A
when [position is less then 41 and greater then 20 = B
when [position is less then 51 and greater then 40 = C

I am not sure exactly how to write that formula?
I appreciate your help.

The Switch() function is handy for cases like this where you have
multiple choices. It takes arguments in pairs; the first member of
each pair is evaluated to see if it is TRUE or FALSE. When it first
encounters a TRUE value it returns the second member of that pair and
quits:

Switch(NZ([position]) <= 0, "OOPS, this should not happen",
[Position] < 21, "A",
[Position] < 41, "B",
[Position] < 51, "C",
True, "Oops, this should not happen either!")


John W. Vinson[MVP]
 
Grade: IIF([position] >0 AND <21, "A", IIF([position] >20 AND <41, "B",
IIF([position] >40 AND <51 "C", "Error")))
 
Back
Top