+ Reply to Thread
Results 1 to 18 of 18

Problems combining IF and MAX to get the right result

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    4

    Problems combining IF and MAX to get the right result

    Hi, I was wondering if anyone could help. Its a tricky question to ask - so I am hoping the answer is more straightforward than the wording of the question! OK Imagine the following table

    Fruit Date Price New Date
    Apple 01/01/00 1
    Apple 02/02/00 2
    Banana 03/03/00 1
    Banana 04/04/00 2
    Pear 05/05/00 1
    Pear 06/06/00 2

    WHat I would like to appear in the New date column is the date that each fruit was at its most expensive, so the table would become:

    Fruit Date Price New Date
    Apple 01/01/00 1 02/02/00
    Apple 02/02/00 2 02/02/00
    Banana 03/03/00 1 04/04/00
    Banana 04/04/00 2 04/04/00
    Pear 05/05/00 1 06/06/00
    Pear 06/06/00 2 06/06/00

    Is there a formula that would provide me with the outcome above.

    Many thanks for your help,

    Paul
    Last edited by Doctorchuckles; 07-31-2012 at 04:27 AM. Reason: Moderator suggestion

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,178

    Re: Trying to find the right formula to....

    See if this helps:

    http://www.dailydoseofexcel.com/arch...ple-variables/


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-30-2012
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Trying to find the right formula to....

    Hi thanks for replying TMS. I've looked through it and I don't think it quite does what I need (although it might just need an easy tweak - of which I am not skilled enough) The example looks at a bunch of data and picks out the maximum (or minimum) for each group. What I need it to do is having found the maximum (or minimum) value, it reports a value from another column. So in my example above, the example you report would allow me to put the maximum price for each of the fruit groups, but not the date it occurred. I hope that makes sense, I can feel sense slipping away with every word I type

    Paul

  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: Trying to find the right formula to....

    Hi Paul and welcome to the forum.

    Will be easier for us to help you, if..

    1) Do, what the Moderator, asked for you

    2) Upload a small sample workbook.
    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.

  5. #5
    Registered User
    Join Date
    07-30-2012
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    4

    Problems combining IF and MAX to get the right result

    Hi Fotis, as suggested I have changed the Title - hope this helps. I have also uploaded a simple example.

    Many thanks,

    Paul
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,178

    Re: Problems combining IF and MAX to get the right result

    =INDEX($B$2:$B$10,MATCH(MAX(IF($A$2:$A$10=A2,$C$2:$C$10)),$C$2:$C$10,0))

    Committed with Ctrl-Shift-Enter rather than just Enter (Array Entered)

    {=INDEX($B$2:$B$10,MATCH(MAX(IF($A$2:$A$10=A2,$C$2:$C$10)),$C$2:$C$10,0))}


    Regards, TMS

  7. #7
    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: Problems combining IF and MAX to get the right result

    Maybe to combine what TMS, suggested(as helper column) and an INDEX&MATCH function.

    So in E2 and copy down, use this Array foemula(C+S+E)

    =MAX(IF($A$2:$A$10=A2,$C$2:$C$10))

    Then in D2 and copy down, this.

    INDEX($B$2:$B$10,MATCH(E2,$C$2:$C$10,0))

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Problems combining IF and MAX to get the right result

    PHere is also Pivot table solution...
    And formula...
    Attached Files Attached Files
    Never use Merged Cells in Excel

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,178

    Re: Problems combining IF and MAX to get the right result

    @Fotis: is that kind of what I said in post #7 but all together?

  10. #10
    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: Problems combining IF and MAX to get the right result

    @TMS

    It's better one, than two!

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,178

    Re: Problems combining IF and MAX to get the right result

    @zbor: neat, I'd never have thought of using a Pivot Table. Suggest you lose the grand total though. Cheers, TMS

  12. #12
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Problems combining IF and MAX to get the right result

    That's cosmetic

  13. #13
    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: Problems combining IF and MAX to get the right result

    @TMS

    Most important for me is to see you here with us, to suggest solutions, again.

    This forum, needs people like you!

  14. #14
    Registered User
    Join Date
    07-30-2012
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Problems combining IF and MAX to get the right result

    Hi TMS, MANY THANKS - this works perfectly I'll go away and look to understand why now

    Many thanks for your solution!!

    Regards,

    Paul

    ---------- Post added at 10:17 AM ---------- Previous post was at 10:11 AM ----------

    Thanks to everyone who helped here. I have at least 3 solution - 3 more than I thought I would have when I arrived at work this morning.

    This site is AWESOME!

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,178

    Re: Problems combining IF and MAX to get the right result

    @Paul: you're welcome.

    @Fotis: I've not been anywhere ... apart from the holiday in Canada (which was very good)

    @zbor: you want it to be pretty though, don't you ... not sure about the lippy and mascara

  16. #16
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,698

    Re: Problems combining IF and MAX to get the right result

    Quote Originally Posted by TMShucks View Post
    =INDEX($B$2:$B$10,MATCH(MAX(IF($A$2:$A$10=A2,$C$2:$C$10)),$C$2:$C$10,0))
    This works for the example given but may not work if the max value is the same for different fruit, e.g. if C5 is changed to 9 you get incorrect results for Pear.

    You need a formula that will check that both the max value and the fruit are the same, i.e. this array formula for example

    =INDEX(B$2:B$10,MATCH(1,(MAX(IF(A$2:A$10=A2,C$2:C$10))=C$2:C$10)*(A$2:A$10=A2),0))

    [edit: or the formula suggested by zbor in attachment!]
    Last edited by daddylonglegs; 07-31-2012 at 05:50 AM.
    Audere est facere

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,178

    Re: Problems combining IF and MAX to get the right result

    @DLL: thank you

  18. #18
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Problems combining IF and MAX to get the right result

    @ Doctorchuckles

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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