+ Reply to Thread
Results 1 to 12 of 12

Find column based on 2 values

  1. #1
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Find column based on 2 values

    I have a table showing products and pricing bands, based on quantity ordered (sample attached)

    The products are in rows with pricing bands in columns.

    If I know the product and the order quantity, how do I find out which band it is in?
    Attached Files Attached Files
    Excel is a constant learning process and it's great to help each other. If any of us have helped you today, a click on the "reputation" star on the left is appreciated.

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Find column based on 2 values

    what would make Prod A with a value of 25 end up in Band 3? It would look like it should either be Band 1 or Band 2 depending on if those numbers are minimum or maximum.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find column based on 2 values

    Oops! Apologies - I'd been playing around with the numbers!
    Prod A with a value of 25 should be in Band 1.
    Last edited by shirleyxls; 10-23-2019 at 04:12 PM.

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Find column based on 2 values

    how many products and bands will you have in your actual data?

  5. #5
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find column based on 2 values

    10 bands and about 10 products

    They're actually product categories so not likely to grow to a large number.

    The quantity band is based on an order quantity UP to (and including) the value shown in that band
    If the quantity is greater than the last band, they will just get the last band value.

    So for Product A, an order of 25 would be Band 1, 55 would be Band 2, 90 would be Band 4

    Hope that helps - this one has got me stumped!
    Last edited by shirleyxls; 10-23-2019 at 04:12 PM.

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Find column based on 2 values

    I did it this way...
    =IFERROR(LOOKUP(2,1/(B4=C9)/(C4:F4<=C10),C3:F3),IFERROR(LOOKUP(2,1/(B5=C9)/(C5:F5<=C10),C3:F3),LOOKUP(2,1/(B6=C9)/(C6:F6<=C10),C3:F3)))
    and I know it can be expanded to cover 10 bands (that is easiest by changing C3:F3 to C3:L3) and increasing the number of lookups to 10 but I know there is an easier way.
    I'll just have to keep playing with it. Someone will probably come along with a simpler version.

  7. #7
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find column based on 2 values

    Thanks Sambo kid. Glad it's not just me that's struggling with this!

    I wanted to make it as dynamic as possible so that if someone adds a new product category we don't have to further expand the formula.

    Appreciate the time spent - let me know if anything else springs to mind :-)

  8. #8
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find column based on 2 values

    Still playing with this but came up with a possible solution using INDIRECT

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I might need to play with the ranges a bit but it seems to work (unless the quantity is less than the lowest value in Band 1, but I'll put an IFERROR in to capture that once I've tested it a bit more)

    Open to more elegant solutions if anyone has any!

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Find column based on 2 values

    Using your original file:

    G9: =MATCH(C9,B4:B6,0)

    G10: =MATCH(C10,INDEX(C4:F6,G9,0))

    G11: =INDEX(C3:F3,G10)

    Text in E10 should read:

    Column on this row is

    You can substitute the individual parts into the formula if you are looking for one composite formula.

    Hope this helps.

    Pete

  10. #10
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find column based on 2 values

    Many thanks Pete! "The column on this row" was the bit which I'd got wrong

    I've now built this into a single formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It works perfectly!

    Thanks again for the solution - much appreciated

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,734

    Re: Find column based on 2 values

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Find column based on 2 values

    Thanks for the rep, Shirley. The composite formula is certainly shorter than the others that have been mentioned.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Find data in a column and count values based on the row that it is in.
    By jdstenton in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2016, 12:07 PM
  2. [SOLVED] Need to find a column number based on values in rows 1 and 2
    By DEB1000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-22-2015, 05:53 PM
  3. Need function to find row and column based on cell values
    By MariPip in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-07-2014, 04:45 PM
  4. Replies: 2
    Last Post: 02-14-2014, 03:04 PM
  5. [SOLVED] Find last value in one column based on values in another (text only)
    By slash_gnr3k in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2012, 11:37 AM
  6. Replies: 5
    Last Post: 09-29-2011, 06:39 AM
  7. [SOLVED] Find and sum values based on a column search
    By Chocolate-Thunder in forum Excel General
    Replies: 4
    Last Post: 08-09-2006, 12:20 PM

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