+ Reply to Thread
Results 1 to 12 of 12

how to use isnull with the iif function?

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    how to use isnull with the iif function?

    I have the field below in one of my queires. The M_OPT_DATA5 field has 5 possabilities one of them being blank... if its blank I'd like to return "NO CODE". How can I add that to what I have below???


    COLLECTIONS: IIf([M_OPT_DATA5]="R","AL",IIf([M_OPT_DATA5]="C","AL",IIf([M_OPT_DATA5]="O","OFF",IIf([M_OPT_DATA5]="S","ARMS",if([M_OPT_DATA5""))))
    Last edited by jgomez; 03-14-2012 at 05:44 PM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: how to use isnull with the iif function?

    Hi. Try this

    =IIf([M_OPT_DATA5]="R","AL",IIf([M_OPT_DATA5]="C","AL",IIf([M_OPT_DATA5]="O","OFF",IIf([M_OPT_DATA5]="S","ARMS",if([M_OPT_DATA5="";""))))


    Hope that helps you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: how to use isnull with the iif function?

    I replaced the ; with ,... doesn't work.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: how to use isnull with the iif function?

    =IIf([M_OPT_DATA5]="R","AL",IIf([M_OPT_DATA5]="C","AL",IIf([M_OPT_DATA5]="O","OFF",IIf([M_OPT_DATA5]="S","ARMS",if([M_OPT_DATA5="","NO CODE"))))

    These with rd color, is true??...and work?

  5. #5
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: how to use isnull with the iif function?

    see query one.
    Attached Files Attached Files

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: how to use isnull with the iif function?

    Can you upload a sample workbook?

  7. #7
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: how to use isnull with the iif function?

    Yes they do.

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: how to use isnull with the iif function?

    Would you upload a sample workbook?

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: how to use isnull with the iif function?

    Can't open your file.....

  10. #10
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: how to use isnull with the iif function?

    ahhh... i can but i guess because its mine.

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: how to use isnull with the iif function?

    ..Propably...

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,720

    Re: how to use isnull with the iif function?

    This works for me.

    
    SELECT accts.ACCT, OPT.M_OPT_DATA5, IIf([M_OPT_DATA5]="R","AL",IIf([M_OPT_DATA5]="C","AL",IIf([M_OPT_DATA5]="O","OFF",IIf([M_OPT_DATA5]="S","ARMS",IIf([M_OPT_DATA5] Is Null,"NO CODE"))))) AS Expr1
    FROM accts LEFT JOIN OPT ON accts.ACCT = OPT.ACCT;
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1