+ Reply to Thread
Results 1 to 8 of 8

complex IF ??

  1. #1
    Forum Contributor
    Join Date
    02-28-2013
    Location
    NY, USA
    MS-Off Ver
    Excel 2019
    Posts
    101

    complex IF ??

    Hi, all
    A newbie using "advanced Excel" functions and in need of help with the following task. Any info will be appreciated. Great many thanks.
    I have three columns of number and one column of ID

    A(ID) B(daily income) C(start) D(end)
    peter 123 120 130
    john 110 245 260
    mary 345 330 340
    judy 234 400 420
    vicky 533 520 550
    . . . .
    . . . .
    . . . .
    . . . .

    I need to identify all of those people, if any, whose daily income falls within any of the predefined income range.
    For example, peter's income would be the first to be compared with ALL the ranges that are defined by column C and D.
    In this case, because peter's income falls within the first bracket, peter is chosen.
    Then john's income is compared with all the ranges defined in column C and D. Unfortunately, his income falls OUTSIDE
    the range of the first bracket so john is not chosen. And so on and so forth.
    In the example above, only peter and vicky are chosen. john, mary and judy do not have the "right" amount of income (not falling in any of the predefined range) and will not be selected.

    I've tried a couple IF commands (actually I didn't really know what I was doing), but none gets me the right results (just by eyeballing the first 100 rows of the table).

    Any help in constructing the right command will be greatly appreciated. Thank you

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,011

    Re: complex IF ??

    In column E

    IF(and(B1>C1,B1<D1),"Select","Not Selected")
    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

  3. #3
    Forum Contributor
    Join Date
    02-28-2013
    Location
    NY, USA
    MS-Off Ver
    Excel 2019
    Posts
    101

    Re: complex IF ??

    I've tried a similar command, but I found that in the example above, if we were to use this command,
    john's income will only be compared to C2 and D2 bracket (245-260) and won't be compared to any other income brackets.
    I need to compare each person's income with ALL different brackets in column C and D before I make a call (whether to include or exclude the person)

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,011

    Re: complex IF ??

    How big is your recordset?

  5. #5
    Forum Contributor
    Join Date
    02-28-2013
    Location
    NY, USA
    MS-Off Ver
    Excel 2019
    Posts
    101

    Re: complex IF ??

    unfortunately, it's BIG.
    1011 IDs
    7000 brackets,
    although I just realized many brackets are duplicates (which I will remove). Still I'd say, brackets are in the range of 2-3000s.

  6. #6
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: complex IF ??

    You want to check the income with range from 1st row till the end with condition :
    if "Select" then stop checking and show the result else continue until end of row?

    If that the case, you need vba.
    See the attachment
    Attached Files Attached Files
    Last edited by SDCh; 03-01-2013 at 12:53 AM. Reason: Add file
    Click (*) if you received helpful response.

    Regards,
    David

  7. #7
    Forum Contributor
    Join Date
    02-28-2013
    Location
    NY, USA
    MS-Off Ver
    Excel 2019
    Posts
    101

    Re: complex IF ??

    In honesty, the example I used in my posting is way simpler than the real case I am working on. In the actual case (not about income, nor bracket) some "brackets" overlap in their ranges they cover. Not only do I need to pick the individuals whose "income" falls within the range of one of the brackets but also identify all the "brackets" those selected individuals' "income" fall in. I hope I am not confusing the readers.

  8. #8
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: complex IF ??

    Sorry confused, because you not upload example that show what you want.

    But look at this attachment 1st and see the result.
    Attached Files Attached Files

+ 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