+ Reply to Thread
Results 1 to 15 of 15

Maximum value by time criteria

  1. #1
    Registered User
    Join Date
    06-13-2016
    Location
    Turkey
    MS-Off Ver
    16
    Posts
    30

    Maximum value by time criteria

    Hi all, I need a function to find maximum value of Count column between Name criteria and between two time criteria, as the same of below image :

    Attachment 662090

    Thanks in advanced.
    Attached Images Attached Images
    Last edited by amir0914; 02-11-2020 at 12:21 AM.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Maximum value by time criteria

    try this array formula:
    =MAX(IF($A$2:$A$33=G2,IF($B$2:$B$33>=H2,IF($B$2:$B$33<=I2,$B$2:$B$33))))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Maximum value by time criteria

    Also an array (shift control enter) but slightly shorter
    =MAX(($A$2:$A$33=G2)*($c$2:$c$33>=H2)*($c$2:$c$33<=I2)*($B$2:$B$33))

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,701

    Re: Maximum value by time criteria

    Quote Originally Posted by amir0914 View Post
    I am not sure if this attachment is your image or a file but it is not valid. If you intended to upload a file please follow the instructions in the yellow banner at the top of the page.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Registered User
    Join Date
    06-13-2016
    Location
    Turkey
    MS-Off Ver
    16
    Posts
    30

    Re: Maximum value by time criteria

    Thanks to benishiryo, your code is working well, Can you also write functons to rnage K1 and L1 for extract first and last item by the same criteria.
    For example for "A1" value in Name field by time criteria, the first value of column Count is "1" and last value is "4". I also have uploaded the sample file. thanks to 6StringJazzer for your guidance.
    Attached Files Attached Files

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Maximum value by time criteria

    you probably addressed the wrong person. you used davsth's formula.

    an array formula for K2:
    =INDEX($B$2:$B$33,MIN(IF($A$2:$A$33=G2,IF($C$2:$C$33>=H2,IF($C$2:$C$33<=I2,ROW($C$2:$C$33)))))-ROW($C$2)+1)

    and for L2:
    =LOOKUP(2,1/(($A$2:$A$33=G2)*($C$2:$C$33>=H2)*($C$2:$C$33<=I2)),$B$2:$B$33)

  7. #7
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Maximum value by time criteria

    for l2 I wold do the same

    for k2 as an array, either
    =INDEX($B$2:$B$33,MIN(IF(($A$2:$A$33=G2)*($C$2:$C$33>=H2)*($C$2:$C$33<=I2),ROW($C$1:$C$32))))

    or

    =INDEX($B$1:$B$33,MIN(IF(($A$2:$A$33=G2)*($C$2:$C$33>=H2)*($C$2:$C$33<=I2),ROW($C$2:$C$33))))

  8. #8
    Registered User
    Join Date
    06-13-2016
    Location
    Turkey
    MS-Off Ver
    16
    Posts
    30

    Re: Maximum value by time criteria

    THank you both, your codes work perfect, I want to type time value manually, but it's not working : (time value replaced with H2 range in above code)

    =MAX(($A$2:$A$33=G2)*($c$2:$c$33>="09:00:01")*($c$2:$c$33<=I2)*($B$2:$B$33))

    Why doesn't time value work right?

  9. #9
    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,460

    Re: Maximum value by time criteria

    That is text. See if this works:

    =MAX(($A$2:$A$33=G2)*($C$2:$C$33>=TIME(9,0,1))*($C$2:$C$33<=I2)*($B$2:$B$33))
    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.

  10. #10
    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,460

    Re: Maximum value by time criteria

    Thanks for the rep.

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

  11. #11
    Registered User
    Join Date
    06-13-2016
    Location
    Turkey
    MS-Off Ver
    16
    Posts
    30

    Re: Maximum value by time criteria

    Thany you AliGW, But my problem hasn't resolved yet, I have another question, I want to put date instead time, is this right :

    =MAX(($A$2:$A$33=G2)*($C$2:$C$33>=date(01/05/2016))*($C$2:$C$33<=date(04/05/2016))*($B$2:$B$33))

    Thanks in advanced.

  12. #12
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,781

    Re: Maximum value by time criteria

    Attach file for new question

  13. #13
    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,460

    Re: Maximum value by time criteria

    The date bit needs to look like this:

    DATE(2016,5,1)

  14. #14
    Registered User
    Join Date
    06-13-2016
    Location
    Turkey
    MS-Off Ver
    16
    Posts
    30

    Re: Maximum value by time criteria

    Thank you AliGW, you did great.

  15. #15
    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,460

    Re: Maximum value by time criteria

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

+ 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. Count with multiple criteria (Date, Time and Other Criteria)
    By Naren_Kumar in forum Excel General
    Replies: 6
    Last Post: 06-25-2018, 05:53 PM
  2. Disable Insert button code works fine, but some times throws Run-Time error '5'
    By challasl in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-18-2016, 05:41 AM
  3. [SOLVED] This macro runs fine the first time, but generates a Type Mismatch error after that.
    By armlegx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2016, 01:46 PM
  4. [SOLVED] Help with modifying VBA Macro - Works fine but needs fine tuning !
    By stefan27 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-06-2015, 10:27 AM
  5. Count hours (time) between four time criteria
    By adhide in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 08-25-2009, 07:43 PM
  6. macro works fine once than scrambles everything the second time
    By drocket in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2007, 04:49 PM
  7. [SOLVED] Sheet moves at print time, loos fine at preview
    By Erich Koch in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 11-27-2005, 11:00 AM

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