IIF then else

  • i am trying to do iif then else in field expression in SSRS

    (if field.city = "dallas" then

    field.state = "texas"

    elseif field.city ="atlanta" then

    field.state = "geogria"

    else

    field.city

    endif )

    can you please let me know do the if then else condition in the expression of the field?

  • Unfortunately, the IIF statement is not as elegant as you would like. The syntax for it is quite similar to the syntax used by Excel...

    IIF (Condition, result if true, result if false)

    For you "Elseif", you would need to use another IIF statement - it gets real ugly if you have a few ELSEIF's.

    So you statment would look something like:

    IIF (Field.city ="dallas", "texas", iif (Field.city="atlanta", "georgria", field.city))

  • You can achieve this using switch statement.

    Add the below expression in state field.

    = switch(Fields!City.Value="dallas","Texas",Fields!City.Value="atlanta","geogria",true,Fields!City.Value)

    Hope this will help you.

    Still you have a problem pls feel free to revert back.

    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    Please feel free to let me know if you are not clear or I’ve misunderstood anything.

    Thanks,
    Arunkumar S P

  • My problem here - I am trying to label my status group as follows,

    Reporting Services / Visual Studio only returns the first true value = "New Provider" for all other records the last statement "Full Time Provider" nothing for on call or part time.

    =IIf(

    Fields!status.Value = "NEW", "New Provider",

    (IIf(Fields!status.Value = "OC", "On-Call Provider",

    (IIf(Fields!status.Value = "PT", "Part Time Provider","Full Time Provider")))))

    Any help is appreciated!

    Thanks

  • Hi, 🙂

    I guess, this can be acheived by using either nested IIf statements or SWITCH statement as

    =Switch(Fields!Value1.Value, "Case1", Fields!Value2.Value, "Case2")

    Please try...this should help... 🙂

    Cheers,

    Niraj Joshi

  • Thanks for the respsonse - did try SWITCH with the same result ... First value is returned correctly, else always the last value in the statement- the two in between are not shown.

  • Just a thought... double-check if your data is uppercase/lowercase. I've sometimes run into issues with SSRS being case-sensitive when evaluating values (i.e, If..Then).

  • yeah - got it, looks in visual studio I can't do spaces

    'Field' = "NEW" - doens't work

    but

    'Field'="NEW' works

    I am so used using spaces in my old sql analyzer.

    Thanks for you help !!! :w00t:

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply