Results 1 to 6 of 6

Thread: AccesS Formula help

  1. #1
    Board Regular
    Join Date
    Jun 2012
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default AccesS Formula help

    I could use some help with how to write this formula in ACCESS to determine age bucket for the column DaysAged. It works fine when I input just the formula for <= 30 days but, when I add 30-60, 60-240, and > 240 it isn't calculating correctly. I'm just not sure how to show the days between 30- 60 and 61 -240 ranges. Any help would be appreciated. Here is the formula I was trying to use.

    NTG AGE BUCKET: IIF([DaysAged]<=30,"<30 Days",IIF([DaysAged]>30<=60,"31-60 Days",IIF([DaysAged]>60,<=240,"61-240 Days",IIF([DaysAged]>240,">240 Days"))))

  2. #2
    Board Regular
    Join Date
    Oct 2008
    Location
    New York, NY
    Posts
    104
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: AccesS Formula help

    If you have multiple conditions you have to separate with 'And' or 'Or' --

    [DaysAged]>30 And [DaysAged] <=60, so it would like something like this --

    IIF([DaysAged]<=30,"<30 Days",IIF([DaysAged]>30 And [DaysAged] <=60,"31-60 Days",IIF([DaysAged]>60 And [DaysAged] <=240,"61-240 Days",IIF([DaysAged]>240,">240 Days"))))

  3. #3
    Board Regular
    Join Date
    Jun 2012
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: AccesS Formula help

    Great!! Thanks for the help.

  4. #4
    Board Regular
    Join Date
    May 2013
    Posts
    652
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: AccesS Formula help

    Is the last IIF actually needed?

    Quote Originally Posted by CPGDeveloper View Post
    If you have multiple conditions you have to separate with 'And' or 'Or' --

    [DaysAged]>30 And [DaysAged] <=60, so it would like something like this --

    IIF([DaysAged]<=30,"<30 Days",IIF([DaysAged]>30 And [DaysAged] <=60,"31-60 Days",IIF([DaysAged]>60 And [DaysAged] <=240,"61-240 Days",IIF([DaysAged]>240,">240 Days"))))
    Office 2007
    Access novice. Sometimes trying to give something back

  5. #5
    Board Regular
    Join Date
    Jul 2010
    Posts
    449
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: AccesS Formula help

    I find the switch function is a clearer and neater option for things like this. If DaysAged returns and integer then:

    Code:
    Switch([DaysAged]<31,"<30 Days",[DaysAged]<61,"31-60 Days",[DaysAged]<241,"61-240 Days",True,">240 Days")
    Note the final True as an argument, this is the equivalent of an Else (if none of the other criteria evaluate to true then this one will and therefore needs to be the last one).

  6. #6
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    16,473
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default Re: AccesS Formula help

    in a like vein:
    Code:
    Switch([DaysAged]<31,"<30 Days",[DaysAged]<61,"31-60 Days",[DaysAged]<241,"61-240 Days",[DaysAged]>=241,">240 Days")

    Using: Office 2010/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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