IIF expression

G

Guest

I am trying to write an expression in a query to evaluate if the value in the
field is high, medium or low to return the value 1, 2, and 3 respectively.
when i write the expression in the following manner, the expression always
returns 0.

Priority Sort: IIf([Data Project Names]![priority]="high",1,0)

Reason i am doing this i am trying to sort my list of projects at work into
high, medium and low priority and using sort ascend will prioritize low over
medium due to the way the alphabet is written. is there another sort
function that can avoid this query expression above all-together.

thanks
 
L

Lynn Trapp

Give this a try:

Priority Sort: IIF([Priority] = "High", 1, IIF([Priority] = "Medium", 2,3)
 
S

Sunny

It worked for me

SELECT columns, IIf(priority='high',1,IIf(priority='medium',2,3)) AS numprio
FROM yourtablename
ORDER BY IIf(priority='high',1,IIf(priority='medium',2,3))

make sure you have 'high', 'medium' and 'low' spelled out correct or you
would get 0.
 

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