+ Reply to Thread
Results 1 to 9 of 9

Counting MAX value in array formula

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Counting MAX value in array formula

    I use array formula all the time to do conditional counting, but I'm having trouble specifying the counting of max values.

    Per row, I need to count the max number of dates present per ID number

    colA = ID number
    colB = Date
    colC = my formula

    As an example I'm using this on row 6, but it is not working as I had hoped:

    {=SUM(IF(A:A=A6,IF(MAX(B:B)=B6,1,0)))}

    It correctly returns 0 when column B isn't a max value. However when it is the max date it counts all the rows where column A values are equal.

    I've been stuck on this for a while. Please can someone help me?

    Kind regards,
    Rob
    Attached Files Attached Files
    Last edited by rjacko10; 07-03-2017 at 06:28 AM. Reason: Added example spreadsheet

  2. #2
    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,719

    Re: Counting MAX value in array formula

    Will you please attach a sample Excel workbook?

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    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.

  3. #3
    Registered User
    Join Date
    04-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Counting MAX value in array formula

    Thanks AliGW - I've just uploaded an example spreadsheet

  4. #4
    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,719

    Re: Counting MAX value in array formula

    Sorry - I don't understand the expected results: why 1 in D8 when there is only one instance of the date? Is this really a counting exercise rather than a sum???

  5. #5
    Registered User
    Join Date
    04-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Counting MAX value in array formula

    Sorry! - I'm trying to count the maximum dates only per ID.

    So in row 8, 08/01/2017 is the maximum date for that ID number, and it only occurs once, so I just want a 1 returned.

    Conversely, rows 4 and 5 share the maximum date for ID 1, so I would like 2 to be returned for both of those rows, as there are 2 maximum dates for this ID number.

    I hope this makes sense!

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Counting MAX value in array formula

    Hi,

    Perhaps this formula array entered (using Ctrl+Shift+Enter) into D2
    =IF(B2=MAX(IF($A$2:$A$10=A2,$B$2:$B$10)),COUNTIFS(A:A,A2,B:B,B2),0)
    note that the blue section should be limited to as few rows as possible for performance reasons.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    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,719

    Re: Counting MAX value in array formula

    So it IS a counting exercise, not a sum!!! Doe post #6 give you your answer?

  8. #8
    Registered User
    Join Date
    04-15-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Counting MAX value in array formula

    Thank you guys!! It seems to work.

    Yes, sorry AliGW, it is counting but I always use SUM(IF('logic statement',1,0)) to do my array counting. I thought this was generically the correct method to use.

  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,719

    Re: Counting MAX value in array formula

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

+ 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. Formula Check?.....Counting the number of 0's in a array.
    By eajustin15 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 03-11-2013, 08:24 PM
  2. Array Formula with Unique Counting gives error
    By dim06 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2012, 09:46 AM
  3. Counting with Array Formula
    By andrewc in forum Excel General
    Replies: 4
    Last Post: 09-12-2011, 04:25 AM
  4. Array formula help, counting size of a dataset!
    By ad9051 in forum Excel General
    Replies: 4
    Last Post: 12-09-2010, 10:06 AM
  5. Sumproduct or array formula for counting criteria of sum of cells
    By jasoncw in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-09-2007, 03:09 PM
  6. counting duplicates within array formula?
    By etmac in forum Excel General
    Replies: 5
    Last Post: 09-05-2006, 04:45 AM
  7. do I need array formula or sumproduct for counting?
    By Karin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-30-2006, 12:55 PM
  8. [SOLVED] Counting with Array Formula
    By Werner Rohrmoser in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-20-2005, 01:05 PM

Tags for this Thread

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