+ Reply to Thread
Results 1 to 11 of 11

Formula to Return cell value based on multiple Max & Min values

  1. #1
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Formula to Return cell value based on multiple Max & Min values

    Hello Again,

    I need a formula to classified a specific price into specific class.

    Example:
    Formula look the column S value (Price) is falling into which category's from columns B:O Max and Mix value.

    Let say S4 value is 80 and it is falling in B4:C4 then the T4 is return C which is B2 value.

    I hope i have explained correctly.

    copy of sample workout is attached for your reference.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to Return cell value based on multiple Max & Min values

    Please double check your values from classes A, AAA, and VIP. In some cases, the Min is greater than the Max. There are also instances in which A has a higher price than VIP, which doesn't seem right. If the prices are all meant to be listed from left to right in ascending order, then you should be able to use the formula below in T4:

    =INDEX($B$2:$O$2,FLOOR(1+MATCH($S4,$B4:$O4,1),2)-1)

    Fill it down and it should work, but again, it requires the prices in B:O to be listed from lowest to highest.
    Attached Files Attached Files
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  3. #3
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Formula to Return cell value based on multiple Max & Min values

    Thanks CAntosh,

    First of all thanks for your valuable help. Actually I am out of town for a while. came back just 1 hour back.

    let me check and let u know the output.

  4. #4
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Formula to Return cell value based on multiple Max & Min values

    Hai Santosh,

    I have a question with the same file.

    Let say after applying ur formula I got the majority of the classification is BBB and some of the items are more than BBB. Might be "C" or "C+".

    Lower classification is not my concerns because the price is already is in low category (Classification).

    My concerns is the higher classification. Is there any formula which will tell me how much discount I am apply in that pricelist to make the classification as per majority.

    Let Say:

    Urine analysis is having the price 126 which is VIP category (Classification). But I need to apply the formula which will tell me how much discount I can ask for the other party to make this pricelist fall in max-min for BBB category.

    Urine Analysis 126
    BBB Min = 91 and Max = 100
    The formula will be 126-SUM(126*25/100)

    The above is manually which is good for 1 or 2 services if you have 1000-6000 services then it is difficult to do so.

    Can we do something for this issue. If so their I will be very thankful to you.

  5. #5
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to Return cell value based on multiple Max & Min values

    If the values are in ascending order from B:O, then you should be able to use the following formula:

    =IF(FLOOR(1+MATCH($S4,$B4:$O4,1),2)-1>8,(S4-I4)/S4,"")

    This formula will remain blank if the class is BBB or worse. If the class is better than BBB, it will return the minimum discount that must be given to lower the class to BBB.

    Hopefully that helps?

  6. #6
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Formula to Return cell value based on multiple Max & Min values

    Hai Santosh,

    Thanks. It works. once last question it is giving 21% where as when I am calculating manually it can be also 25%.

    ofcourse I will see my benefits which is 25% discount.

    Can it be something like discount can be inbetween 21-25 just formula suggesting we can ask for 21 to 25 discounts. means discount can be 21, 22,23,24 or 25.

  7. #7
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to Return cell value based on multiple Max & Min values

    This formula should give you the discount range that would land you in BBB, again assuming that all of the values are corrected to be in ascending order:

    =IF(FLOOR(1+MATCH($S4,$B4:$O4,1),2)-1>8,TEXT((S4-I4)/S4,"0.0%")&" - "&text((S4-H4)/S4,"0.0%"),"")

    Some of the percentages for the discounts for the lower priced items might look off because the prices in your table appear to be round numbers, but they're actually decimals that have been rounded (for example, cell I7 shows 28, but it's actually 27.5). The discount math should work if you're looking at the actual price in each cell and not just the price being displayed.

  8. #8
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Formula to Return cell value based on multiple Max & Min values

    thanks 4 ur valuable help.

    I will check it 2maro and let u know.

    I will appreciate if you can explain the formula so that I can know what I am doing and why these functions have been used.

  9. #9
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to Return cell value based on multiple Max & Min values

    It looks more complicated than it is because you have merged cells in B2:O2, so we have to identify the FIRST of the two cells for each range in order to return the class. For instance, H2 returns "BBB", but I2 is blank.

    FLOOR(1+MATCH($S4,$B4:$O4,1),2)-1

    achieves the match to the class. It matches S4 against the ascending values in B4:O4 and returns the greatest value equal to or beneath S4. We then add one to that value and round down (using FLOOR) to the next lowest even number, then subtract 1 to get the match with the class name. That sounds confusing, but walk through it with two examples and it'l be clearer. If the price of TSH is 100, then the MATCH will return the 5th value between B4 and O4. We then add one (total now 6), round down to the next lowest even (still 6), and subtract one (now 5). INDEX then returns the 5th value in B2:O2, which is "B". If TSH were 104, MATCH would return 6, because it's the 6th value in B4:O4. We then add 1 (now 7), round down to the next lowest even using FLOOR (now 6), then subtract 1 (now 5), and use INDEX to return the 5th value in B2:O2, which is again "B".

    INDEX is used in my original formula to return the class. In my second formula for the discount range, we just use the FLOOR part and a ">8" to determine if the class match is greater than BBB, which is the 7th/8th option in B2:O2. If the class is greater than BBB, then (S4-I4)/S4) returns the minimum discount that would get us to the top of the BBB range. TEXT((S4-I4)/S4,"0.0%") transforms that number into a percentage. &" - "& simply adds a dash to the middle of the discount range. TEXT((S4-H4)/S4,"0.0%") returns the discount that would get us to the bottom of the BBB range, also with TEXT to make it appear as a percentage.

    All put together, it should get you what you're looking for. To go through an actual example step by step, select a formula cell and click on "Evaluate Formula" on the "Formulas" tab and it'll walk you through the selected formula one step at a time. Hope this helps!

  10. #10
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Formula to Return cell value based on multiple Max & Min values

    Hai Santosh,

    Thanks for the explanation. It works for me.

    If I have any query I will get back to you.

    topic marked as solved and reputation added.

  11. #11
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Formula to Return cell value based on multiple Max & Min values

    Great, thank you. Good luck!

+ 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. return multiple header cell values into one cell concatenated based on a cell value
    By anchuri_chaitanya in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-13-2016, 10:27 PM
  2. Return Cell Value based on Values in Multiple Columns
    By Cardan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-13-2015, 10:20 PM
  3. [SOLVED] How to return multiple values to a single cell based on multiple criteria
    By lwallace in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-20-2014, 06:32 AM
  4. Array formula to return multiple values based on various (OR) criteria
    By dancing-shadow in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-20-2013, 05:12 AM
  5. need a formula to return multiple values based on cell refrance please help
    By crobledo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-10-2013, 10:16 PM
  6. Replies: 3
    Last Post: 05-09-2012, 06:22 PM
  7. Replies: 6
    Last Post: 06-08-2010, 09:42 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