Multiple IIF statements in an expression

HeatherBrian

New Member
Joined
Oct 26, 2004
Messages
23
I am trying to create an IIF statement that takes multiple items into account. I am able to write each if statement separately but an not sure how to combine them. I want both IIF statements to be under the expression actor. I need the following information to be returned. If Test1S is No than Factor is null; however, if Test1S is yes and Worksheet-General Information is yes than 75 otherwise 100. The purpose of this is to score different sections of an exam. If they do not need to complete Test1S than they should not receive any credit; however, if they have to complete they will either receive 100 (if no mistakes) or 75 (if mistakes).

Any help would be greatly appreciated.

Thanks.


Factor: IIf([Worksheet-General Information]=Yes And [Test1S]=Yes,75,100)


Factor1: IIf([Test1S]=No,Null)
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

giacomo

Well-known Member
Joined
Feb 20, 2002
Messages
1,796
if Test1S is No than Factor is null
if Test1S is yes and Worksheet-General Information is yes than 75
otherwise 100

sounds like you need a nested if:

Factor: IIf([Test1S]=No, null, iif([Worksheet-General Information]=Yes,75,100))

hth,
Giacomo
 

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,352
It would be much easier and clearer to read your SQL if you just built a custom function to insert into the SQL.

As a limited explanation, when writing a code module, you can specify parameters to be passed to it. So what you do is something like:

Code:
SELECT functionNameHere([fieldname1],[fieldname2]) FROM tblName

Public Function functionNameHere(ByVal fld1 As String, ByVal fld2 As String) As String

' put code here to work with the contents of the two variables passed
' to it and then return a result by setting it equal to the function name
' using a code module lets you do things like embed if...then...else
' or Select Case statements

functionNameHere = whatever_you_want

End Function

Mike
 

Watch MrExcel Video

Forum statistics

Threads
1,113,920
Messages
5,545,029
Members
410,647
Latest member
bernardazar
Top