Sunday, February 19, 2012

IIF driving crazy

This is driving me crazy…

=IIF(Fields!COUNTRY.Value = "United States","US",

IIF(Fields!COUNTRY.Value = "UNITED STATES", "US", Fields!COUNTRY.Value))

Is that not correct ?

=Iif(Fields!Country.Value = "United States", "US", Nothing)

=Iif(Fields!COUNTRY.Value = "United States", "US")

=Iif(Fields!COUNTRY.Value, "misb_db_prp1" = "United States", "US", Fields!COUNTRY.Value, "misb_db_prp1")

=Iif(Fields!COUNTRY.Value = "United States","US", Fields!Country)

Can you please correct what im doing wrong?

Thanks

Can you be more specific with your problem? What is happening when you try to use this expression? Thanks.|||

i want to display only "US" wherever = "United States" or "UNITED STATES"

i have tried but nothing is change still "United States" is displaying

=Iif(First(Fields!COUNTRY.Value, "db")

= "United States", "US", First(Fields!COUNTRY.Value, "db"))

|||

Try this:

=IIF(Fields!COUNTRY.Value.ToString().ToLowerInvariant().Equals("united states"),"US", Fields!COUNTRY.Value)

|||

getting this error:

'ToLowerInvariant' is not a member of 'String'.

|||

It's part of SSRS2005.... if you bring up an expression editor dialog, and type something like this:

=1.ToString().ToLowerInvariant()

the intellisense should popup as soon as you type the period after the ToString(), and you can scroll nearly to the bottom and see if it is there.

Also, instead of nesting several IIf statements, it can be easier to use a Switch statement.

sluggy

|||

i'm using sql server reporting 2000 so there is no intellisense

can you give me the samp of using switch statement ?

|||

try

=Iif(trim(Fields!Country.Value) = "United States", "US", "")

|||

i have other countries other then USA

=Iif(trim(Fields!Country.Value) = "United States", "US", "")

the above code will be blank, if i have countries other then US

is that not correct?

thanks

|||

What you need is this:

=Iif(trim(Fields!Country.Value) = "United States", "US", Fields!Country.Value)

The IIf is similar to the tenary "?" statement. The syntax for the IIf statement is:

IIf(<expression>, <val/expr to return if true>, <val/expr to return if false>)

All this is included in the books online if you have it installed.

sluggy

No comments:

Post a Comment