Ofer said:
This code is fine, there is a criteria for the first iif, and it someting
like that
IIF(IIF(Field = "A","Display X","Display Y")<0.7,0,"Test1")
So the first iif compare the outcome of the second iif to 0.7 and if true it
returns 0 and if false it returns Test1.
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.
Good luck
Ofer,
Yes, now that I can see the original code snippet, I can see that the
first parameter of the outer IIF does have a conditional test.
From the OP's first post:
"In the example: IIF(IIF(Field = "A","Display X","Display Y"),"Test1")
Test1 is always displayed. Is there any use that this outer IIF with
no
test expression serves ?"
I took the whole function, and took out the [] and added some _ so I
could put it into a VBA fuction.
Public Sub BigIIfTest()
Dim CB As Double
Dim WCB As Double
Dim CallBackPercentage As Double
Dim TestResults As Double
WCB = 0.1
CB = 5
CallBackPercentage = 0.1
TestResults = _
IIf( _
IIf(CB - (CB * (CallBackPercentage - WCB)) / WCB < CB * -1.5 _
, CB * -1.5 _
, IIf(CB - (CB * (CallBackPercentage - WCB)) / WCB > CB *
1.5 _
, CB * 1.5 _
, CB - (CB * (CallBackPercentage - WCB)) / WCB _
) _
) / CB < 0.7 _
, 0 _
, IIf(CB - (CB * (CallBackPercentage - WCB)) / WCB < CB * -1.5
_
, CB * -1.5 _
, IIf(CB - (CB * (CallBackPercentage - WCB)) / WCB > CB *
1.5 _
, CB * 1.5 _
, CB - (CB * (CallBackPercentage - WCB)) / WCB _
) _
) _
)
Debug.Print TestResults
End Sub
When CallBackPercentage is .1, the function returns 5.
When CallBackPerecentage is .5, the function returns 0.
This means that the function does not always return one value.
Ofer has located the test in the outer IIf first parameter, and the
above shows that the function can return more than one value with
varying input.
(Note: Yes, I am aware that the data I used isn't the same as the OP's
data,
Sincerely,
Chris O.