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



Answer this question

IIF driving crazy

  • Yicong Shen

    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


  • briane

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

    can you give me the samp of using switch statement


  • ajb2528

    getting this error:

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


  • LLL1111111111111

    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"))


  • NatalieE

    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


  • ChampAmp

    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


  • pmpmpm

    Try this:

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


  • beto81

    Can you be more specific with your problem What is happening when you try to use this expression Thanks.
  • Simon Gorski

    try

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



  • IIF driving crazy