Search code examples
ms-accessmultiple-conditionsiif

IIf And statement with multiple conditions


I'm very new to Access. I'd like to make a column which has two conditions to result in "1" or "0".

The two conditions are:

If the session ID is smaller than 154 AND their level average is bigger than the current level, "1" is assigned, otherwise, "0".

AND

If the session ID is equal to or bigger than 154 AND the exam average is more than 2, "1" is assigned, otherwise, "0".

The syntax that I wrote is below, but it didn't work - returns 0 for every cell.

IIf([Session_ID]<154 And [Level_Avg]>[Current_Lvl],"1","0") And IIf([Session_ID]>=154 And [Exam_Avg]>=2,"1","0")

Could anyone take a look? Any comments are very appreciated. Thank you!


Solution

  • Most likely you need an OR operator between the two conditions as either one should return the 1 option, otherwise return 0.

    IIf(([Session_ID]<154 And [Level_Avg]>[Current_Lvl]) Or ([Session_ID]>=154 And [Exam_Avg]>=2), 1, 0)