Answered by:
iif expression

Question
-
I have this expression in a text box.
=IIf(Fields!vtext.Value =
nothing,fields!vnumber.Value,IIF(fields!vnumber.Value = nothing and fields!vtext.value = nothing,fields!vdollar.Value,fields!vtext.value))
When I run the report vtext will display and vnumber will display but not vdollar.
HELP!
Thanks.Tuesday, February 10, 2009 9:08 PM
Answers
-
Ok than. You probably want an expression that does this:
if (Fields!vtext.Value <> nothing)
{
textbox.Value = fields!vtext.Value
}
else
{
if(Fields!vnumber.Value <> nothing)
{
textbox.Value = fields!vnumber.Value
}
else
{
textbox.Value = fields!vdollar.Value
}
}
which maps out to this expression:
=IIf(Fields!vtext.Value <> nothing,Fields!vtext.Value,IIF(fields!vnumber.Value <> nothing,fields!vnumber.Value,fields!vdollar.Value))
That should do it.- Marked as answer by Raymond-Lee Friday, February 20, 2009 5:04 AM
Tuesday, February 10, 2009 9:46 PM
All replies
-
Hi smandl,
Your expression evaluates to this in pseudo code:
if(Fields!vtext.Value == nothing)
{
textbox.Value = fields!vnumber.Value
}
else
{
//fields!vtext.value == nothing will always evaluate to false
if(fields!vnumber.Value == nothing && fields!vtext.value == nothing)
{
textbox.Value = fields!vdollar.Value
}
else
{
textbox.Value = fields!vtext.Value
}
}
vdollar will never display because (fields!vtext.value == nothing) will never be true due to the first condition check of (Fields!vtext.Value == nothing). If (Fields!vtext.Value == nothing) is true, than vnumber is displayed, if it's false than we hit the else statement. You should modify your expression statement to be this:
=IIf(Fields!vtext.Value = nothing,fields!vnumber.Value,IIF(fields!vnumber.Value = nothing,fields!vdollar.Value,fields!vtext.value))
Hope that helps.- Proposed as answer by Kevin CheukMicrosoft employee Tuesday, February 10, 2009 9:21 PM
Tuesday, February 10, 2009 9:18 PM -
Now only vnumber will display.Tuesday, February 10, 2009 9:27 PM
-
When do you want to display vtext, vnumber and vdollar? If you can write it out in pseudocode, I can help you construct a expression statement.Tuesday, February 10, 2009 9:31 PM
-
One of those 3 will always have a value. I want to display of those 3 which ever has a value.Tuesday, February 10, 2009 9:34 PM
-
Ok than. You probably want an expression that does this:
if (Fields!vtext.Value <> nothing)
{
textbox.Value = fields!vtext.Value
}
else
{
if(Fields!vnumber.Value <> nothing)
{
textbox.Value = fields!vnumber.Value
}
else
{
textbox.Value = fields!vdollar.Value
}
}
which maps out to this expression:
=IIf(Fields!vtext.Value <> nothing,Fields!vtext.Value,IIF(fields!vnumber.Value <> nothing,fields!vnumber.Value,fields!vdollar.Value))
That should do it.- Marked as answer by Raymond-Lee Friday, February 20, 2009 5:04 AM
Tuesday, February 10, 2009 9:46 PM -
Hello,
This can be done by just concating the values, instaed of using IIF expression. If the field has a value then it will display or else not.
Expression:
=Fields!vtext.Value & Fields!vNumber.Value & Fields!vDollar.Value
Hope helpful...
Pavan http://www.ggktech.comWednesday, February 11, 2009 6:48 AM -
That worked really well.
Thanks so much for your help.
smandlWednesday, February 11, 2009 2:05 PM