IIF statement

iuphim

Registered User.
Local time
Yesterday, 22:03
Joined
Oct 30, 2008
Messages
43
I have 2 questions, but I think they are similiar in definitions. They are the the iif statements below. I don't understand what this is doing. Can someone translate for me, please?

IIf([PP 6 Month Unit Sales] Is Not Null,IIf([preferred cost] Is Not Null And [preferred cost]>Cost_Change_Items!COST1,[PP 6 Month Unit Sales]*(Cost_Change_Items!COST1-[preferred cost])*2,0),0)


and

IIf([NC 6 Month Unit Sales] Is Not Null,[NC 6 Month Unit Sales]*(Cost_Change_Items!COST1-Cost_Change_Items!COST_AMT_1)*2,0)


Thanks.
 
Copy to Word and reformat to the true and false parts for easy reading.


Code:
IIf([PP 6 Month Unit Sales] Is Not Null,
   IIf([preferred cost] Is Not Null And [preferred cost]>Cost_Change_Items!COST1,
      [PP 6 Month Unit Sales]*(Cost_Change_Items!COST1-[preferred cost])*2,
   0),
0)
and

Code:
IIf([NC 6 Month Unit Sales] Is Not Null,
    [NC 6 Month Unit Sales]*(Cost_Change_Items!COST1-Cost_Change_Items!COST_AMT_1)*2,
0)

Brian
 
I have 2 questions, but I think they are similiar in definitions. They are the the iif statements below. I don't understand what this is doing. Can someone translate for me, please?

IIf([PP 6 Month Unit Sales] Is Not Null,IIf([preferred cost] Is Not Null And [preferred cost]>Cost_Change_Items!COST1,[PP 6 Month Unit Sales]*(Cost_Change_Items!COST1-[preferred cost])*2,0),0)


and

IIf([NC 6 Month Unit Sales] Is Not Null,[NC 6 Month Unit Sales]*(Cost_Change_Items!COST1-Cost_Change_Items!COST_AMT_1)*2,0)


Thanks.

If you apply the Basic Definition of IIf() (See Below), you, get more information.
Code:
[B]IIf([I][COLOR=red]Condition to Test[/COLOR][/I], [I][COLOR=seagreen]Value If[/COLOR] [COLOR=red]Condition[/COLOR] [COLOR=seagreen]is True[/COLOR][/I], [I][COLOR=purple]Value if[/COLOR] [COLOR=purple][COLOR=#ff0000]Condition[/COLOR][/COLOR][COLOR=#000000] [/COLOR][COLOR=purple]is False[/COLOR][/I])[/B]
IIf([PP 6 Month Unit Sales] Is Not Null,IIf([preferred cost] Is Not Null And [preferred cost]>Cost_Change_Items!COST1,[PP 6 Month Unit Sales]*(Cost_Change_Items!COST1-[preferred cost])*2,0),0)

Notice that the Value if Condition is True
part of this IIf Statement contaions another IIf() Statement.

IIf([preferred cost] Is Not Null And [preferred cost]>Cost_Change_Items!COST1,[PP 6 Month Unit Sales]*(Cost_Change_Items!COST1-[preferred cost])*2,0),0)
and
IIf([NC 6 Month Unit Sales] Is Not Null,[NC 6 Month Unit Sales]*(Cost_Change_Items!COST1-Cost_Change_Items!COST_AMT_1)*2,0)

Does this make any more sense?
 
So in other words, this statement is saying anything in [preferred cost] that is not a null value but is greater than cost1, then the true value would be (((pp 6 month unit sales*cost1)-[preferred cost])*2). but if false then "0". But if [pp6month unit sales] is null, then overall, the statement should be false, "0".

For example:

[prefferred cost] = 56
cost_change_items!cost1 = 40
[pp 6 month unit sales] = 20

So in this case:
It should be 56>40, (((20*40)-56)*2), 0 --> 1,488
But if the [preferred cost] is null or a blank field, then the data would go directly to "0". I am correct?

Thank you for the quick reply. You guys are a great help!
 
I can't do arithmetic only logic :), but that looks about right.

Brian
 

Users who are viewing this thread

Back
Top Bottom