+ Reply to Thread
Results 1 to 10 of 10

Problem with countif, index and sequence

  1. #1
    Registered User
    Join Date
    03-21-2023
    Location
    Ho Chi Minh
    MS-Off Ver
    office 365
    Posts
    4

    Problem with countif, index and sequence

    Dear all,
    I have a problem when using countif on the result of index with sequence. As the attachment, I would like to count how many A1 in the first ten largest of sum.
    Firstly, I take successfully first ten largest of sum by using: index(sort(A1:C31,3,-1),sequence(10),2) (in E2) but when I put this formula into countif to count how many A1 in the result, it returns error in value: countif(index(sort(A1:C31,3,-1),sequence(10),2),"A1") (in F2).
    The problem is from sequence in index but I don't know how to solve it.
    Any help would be greatly appreciated.
    Thank you.

    Phung
    Attached Files Attached Files
    Last edited by nhphung; 03-21-2023 at 10:27 PM.

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Problem with countif, index and sequence

    Hello nhphung. Welcome to the forum.

    Please try this formula in cell F2.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Problem with countif, index and sequence

    Or similarly
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-21-2023
    Location
    Ho Chi Minh
    MS-Off Ver
    office 365
    Posts
    4

    Re: Problem with countif, index and sequence

    Thank you Dave for your prompt response.
    I am sorry because I let you misunderstand my issue. I would like to count how many element whose 'Result' value is "A1" there are in the first 10 largest of 'Sum'. I can get this result if I write in cell F2: =countif(E2:E11,"A1") but I don't want to create the temporary result in E2. Is there any way to calculate directly the value without using the temporary array.
    Thank you.

  5. #5
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Problem with countif, index and sequence

    I assume you're trying to get 1 number that represents the number of times "A1" is in the top 10?

    If this is true, then here's an option:

    =LET(a,TAKE(SORTBY(B2:B31,C2:C31,-1),10),ROWS(FILTER(a,a="A1")))

  6. #6
    Registered User
    Join Date
    03-21-2023
    Location
    Ho Chi Minh
    MS-Off Ver
    office 365
    Posts
    4

    Re: Problem with countif, index and sequence

    Thank Gregb11. It is what I want. Thank you very much.

  7. #7
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Problem with countif, index and sequence

    You’re welcome.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Problem with countif, index and sequence

    Quote Originally Posted by nhphung View Post
    Thank you Dave for your prompt response.
    I am sorry because I let you misunderstand my issue. I would like to count how many element whose 'Result' value is "A1" there are in the first 10 largest of 'Sum'. I can get this result if I write in cell F2: =countif(E2:E11,"A1") but I don't want to create the temporary result in E2. Is there any way to calculate directly the value without using the temporary array.
    Thank you.
    I thought that is what my formulas (both of them) did.

    What am I missing?

    Edit: Never mind. After looking at Gregb11's solution I figured out that I misinterpreted the instructions.
    Last edited by FlameRetired; 03-21-2023 at 11:28 PM.

  9. #9
    Registered User
    Join Date
    03-21-2023
    Location
    Ho Chi Minh
    MS-Off Ver
    office 365
    Posts
    4

    Re: Problem with countif, index and sequence

    The Gregb11's formula works but I don't understand why my formula does not work. Anyone can explain why performing countif directly on the result of index causes error on value?

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Problem with countif, index and sequence

    The first argument in COUNTIF will not receive an array or other calculation. It must define a Range. This can be done by at least 3 different means:
    1. direct referencing like C4:C12 or H1:L150, etc.
    2. using OFFSET or
    3. or defining the upper and lower limits of the range via an INDEX(range,1st-row#,1st-column#):INDEX(range,last-row#,last-column#)

    The latter one is tedious to built but avoids the volatility of OFFSET.

    It appears you were attempting to do that last method and weren't quite able to complete it.
    Last edited by FlameRetired; 03-22-2023 at 04:54 PM.

+ 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. After filtered, index maintaining sequence
    By josephteh in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-19-2023, 03:27 PM
  2. [SOLVED] How to ignor #N/A with INDEX, SORT and SEQUENCE formula
    By Larry1957 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-02-2022, 07:27 PM
  3. [SOLVED] Index/Sort/Sequence with criteria
    By Maike in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-03-2022, 02:25 PM
  4. #NA Problem with Index, Match, Countif formula
    By KATPIF in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-19-2014, 09:43 AM
  5. [SOLVED] IF,COUNTIF, INDEX,MATCH problem to list-out eligible name list.
    By pejoi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-25-2013, 06:25 AM
  6. How to use Countif to test if a sequence appears within an array ?
    By masterinex in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-29-2013, 05:11 AM
  7. Index Match / Countif / Offset problem
    By smalone in forum Excel General
    Replies: 1
    Last Post: 03-12-2009, 06:15 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