+ Reply to Thread
Results 1 to 5 of 5

Explanation sought for MAX function with multiple criteria solution and efficiency

  1. #1
    Registered User
    Join Date
    05-15-2016
    Location
    Nottingham, England
    MS-Off Ver
    2007
    Posts
    3

    Explanation sought for MAX function with multiple criteria solution and efficiency

    The problem that I had was to find the maximum value of a range in one column (column E, Score, in the example) when matching values in 3 other columns (column A, Location, column B, Date, column C, Time). This will give the best score achieved for each event (time) on each day.
    A simple example worksheet is attached.
    Referring to a previous post I saw the following solution posted by JohnTopley:
    "Try
    =MAX(IF(condition1)*(condition2)*(condition3), Result))
    Entered with Ctrl+Shift+Enter
    ..."
    and this was expanded by José Augusto which gave me:
    Please Login or Register  to view this content.
    In looking at the referenced post and others, I also learned about array functions and realised that I had already created this one:
    Please Login or Register  to view this content.
    but I hadn't entered it with Ctrl/Shift/Enter!!!

    Each solution works in my example worksheet; I’ve used both in column G (Formulae) to demonstrate this.
    My problem is, I don’t understand the solution offered in the previous post which uses multiplication of text fields. I suspect it involves the effect of True/False in the ‘calculations' but I'm not sure.
    Can anyone explain this for me, please?
    I can use my own nested IF formula because I understand it (more). However, my worksheet is quite large, currently well over 200,000 rows and growing by the week, so I would be very interested to know whether one formula would be more efficient that the other.
    I intend to copy/paste values to remove the formulae and obviate the performance issue but I need to apply the formula to the voluminous historical data in the first instance so this is still of interest to me.

    Looking forward to any comments.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,678

    Re: Explanation sought for MAX function with multiple criteria solution and efficiency

    I noticed in the IF statement there is no check for column A

    =MAX(IF($B$2:$B$13=B2,IF($C$2:$C$13=C2,$E$2:$E$13)))

    so the other formula could be ..

    =MAX(IF(($B$2:$B$13=B5)*($C$2:$C$13=C5),$E$2:$E$13))

    the "*" is interpreted as an "AND" condition ("+" is an "OR" condition) so the above translates as "if $B$2:$B$13=B5 is TRUE AND $C$2:$C$13=C5 is TRUE then get value from E"

    TRUE is transformed into a 1 and FALSE is 0

    Select a cell with the formula, click "Formulas" then "Evaluate Formula" and yo will see how this works.

  3. #3
    Registered User
    Join Date
    05-15-2016
    Location
    Nottingham, England
    MS-Off Ver
    2007
    Posts
    3

    Re: Explanation sought for MAX function with multiple criteria solution and efficiency

    Thank you so much for the explanation. I was sort of on the right track even in ignorance.
    I made a mistake to begin with in my example file because it didn't allow for two events at different locations at the same time. I changed the nested IF and amended the post incorrectly (copying the wrong formula) and it also 'got lost' when I uploaded the sample file again. User error and poor Change Control!
    My nested IF does now read:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-15-2016
    Location
    Nottingham, England
    MS-Off Ver
    2007
    Posts
    3

    Re: Explanation sought for MAX function with multiple criteria solution and efficiency

    ... and as your solution is shorter than nested IFs, it would presumably be more efficient.
    I'll close the thread, satisfied.
    Thanks

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,215

    Re: Explanation sought for MAX function with multiple criteria solution and efficiency

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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. Replies: 4
    Last Post: 07-17-2016, 12:21 AM
  2. Combine multiple rows in a specific column based on matching criteria? VBA solution?
    By hopegriffin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2015, 07:11 PM
  3. Replies: 1
    Last Post: 03-17-2014, 10:23 AM
  4. [SOLVED] Explanation and/or solution needed
    By bunjijumper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2011, 06:45 AM
  5. Replies: 2
    Last Post: 05-25-2010, 06:55 PM
  6. Replies: 2
    Last Post: 09-18-2009, 07:07 PM
  7. Advice sought: Multiple column sorting
    By davidm in forum Excel Formulas & Functions
    Replies: 31
    Last Post: 09-06-2005, 06:05 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