none
Problem with nested iif

    Question

  • Hi,

    I am trying to produce the correct results to pick up a phone number.

    If the telephone has a value, then show this number, if the telephone does not have a number then use the Home-Tel.

    If the Home-tel has a number then use the Mobile number.

    My expression below does not pick up all the numbers, and i think it may be because sometimes two of the numbers have values.

    =IIF(Fields!Telephone.Value > 0, Fields!Telephone.Value, IIF(Fields!Home_Tel.Value > 0, 
    Fields!Home_Tel.Value, Fields!Mobile.Value))

    Can someone help please?




    M Stoker

    Friday, July 26, 2013 3:44 PM

Answers

  • Hi LordLucan,

    you can try this:

    =IIF(IsNothing(Fields!Telephone.Value) = false, Fields!Telephone.Value, IIF(IsNothing(Fields!Home_Tel.Value) = false, Fields!Home_Tel.Value, "No Phone#"))


    Regards Harsh

    • Marked as answer by LordLucan Monday, July 29, 2013 9:36 AM
    Monday, July 29, 2013 8:51 AM

All replies

  • Have you try retrieving the length (LEN) of telephone numbers(may require conversion) and comparing the length with zero ?

    Regards, RSingh

    Friday, July 26, 2013 4:09 PM
  • hi,

    please check this

    IIF(Fields!Telephone.Value IS NOT NULL, Fields!Telephone.Value, IFF(Fields!Home_Tel.Value IS NOT NULL, Fields!Home_Tel.Value, "No Phone#"))

    I hope this is helpful.


    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid

    MCSE Data Platform
    MCITP: SQL Server 2008 Administration/Development
    MCSA SQL Server 2012
    MCTS: SQL Server Administration/Development

    MyBlog

    Friday, July 26, 2013 5:14 PM
  • Hi Elmozamil,

    I am using Visual Studio 2008 and it says null is no longer supported, is there a workaround?


    M Stoker

    Monday, July 29, 2013 8:08 AM
  • Hi LordLucan,

    you can try this:

    =IIF(IsNothing(Fields!Telephone.Value) = false, Fields!Telephone.Value, IIF(IsNothing(Fields!Home_Tel.Value) = false, Fields!Home_Tel.Value, "No Phone#"))


    Regards Harsh

    • Marked as answer by LordLucan Monday, July 29, 2013 9:36 AM
    Monday, July 29, 2013 8:51 AM
  • Thanks Harsh, that has resolved my problem.

    M Stoker

    Monday, July 29, 2013 9:37 AM