+ Reply to Thread
Results 1 to 9 of 9

Count fields after sort with conditions

  1. #1
    Registered User
    Join Date
    06-08-2021
    Location
    Ontario, Canada
    MS-Off Ver
    2016
    Posts
    5

    Count fields after sort with conditions

    I am trying to alter a sheet which contains the following command:

    =COUNTIF(Table1[PRS Review Date],"<="&TODAY()-21)

    What this does show however is the total for ALL parts in the column. I have sorted the sheet to only show the parts applicable to me, thus this total is completely wrong.

    How can I display the same data but for ONLY the parts which are being shown after sorting?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count fields after sort with conditions

    It sounds like you have a second criteria for the relevant parts, as well as the date criteria you are already using,

    Use a COUNTIFS function with an extra criteria that identifies your parts.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-08-2021
    Location
    Ontario, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Count fields after sort with conditions

    -Richard Buttrey

    "second criteria for the relevant parts"

    Maybe I'm not understanding what you mean but there is only one criteria:

    Count of dates which are 21 days ago or older BUT I only want the count shown for the rows which are displayed and not for all the rows in the sheet.

    I hope that clears it up a little more.
    Thank you for your help

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count fields after sort with conditions

    Hi,

    I interpreted your indication that you had sorted the data to show just the rows you require as meaning there is a second criteria.
    In other words what is determining which rows you show?

    The request is not clear, at least to me.

    You are saying you want to see the total for all parts but seemingly sorting the data to show just your parts.

    Please upload the workbook and manually add the result you expect clearly identifying which are the result cells and which are original data. It's always easier if we can see requests in the context of their workbook.

  5. #5
    Registered User
    Join Date
    06-08-2021
    Location
    Ontario, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Count fields after sort with conditions

    Hello Richard,

    I cannot upload as that will release too much information (596kb - company thing).

    Let me try again:

    We have two people using the sheet. Person A and Person B.

    Person A is responsible for reviewing suppliers 1-20, Person B has 21-41. (they actually have names)

    If I am Person A, I sort the column "Supplier" and select only my suppliers.

    With the formula above, (Column PRS Review Date) it still shows in MY count how many parts both Person A AS WELL AS Person B have NOT updated in the past 21 days. I want this field to only show the count of parts which were not updated by me (Person A) which I have displayed. If I was to display ALL parts, the count would be correct, but once I sort by Person A parts only, the formula still shows the total for both Person A and Person B (even though data for Person B is NOT displayed).

    Does that help clarify my mess?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count fields after sort with conditions

    We don't need to see zillions of original rows or irrelevant sheets. What we do need to see is your request in context. Experience tells us that these sorts of explanations are easily misinterpreted.

    Just anonymise any sensitive data, we don't mind how many M Mouse, or D Ducks you use.

  7. #7
    Registered User
    Join Date
    06-08-2021
    Location
    Ontario, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Count fields after sort with conditions

    Created sample

    Naturally my newbiness is showing since I cannot make the countif work in the 5 minutes I'm spending on this (sorry at work)

    If I sort by buyer A, my total should be 2 as two dates are =<21 days before today. In my company sheet the answer would be 4 even though only buyer A is filtered.

    I want the count displayed for ONLY the buyer selected (showing on screen).

    Does this make it a bit clearer?
    Attached Files Attached Files

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count fields after sort with conditions

    There is no simple function that will return the first value in a filtered list.

    There is a formula solution using COUNTIFS() that requires a helper column with a complicated array formula. However since a helper column is needed it seems more appropriate to use a Pivot Table which is more elegant and more flexible.

    See attached
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-08-2021
    Location
    Ontario, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Count fields after sort with conditions

    Thank you, this 2/10 user is going down the vlookup rabbit hole how :D

    A learning experience for sure!

+ 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. [SOLVED] insert text in fields (possibly mulitple) if certain conditions met
    By JeninQC in forum Excel General
    Replies: 9
    Last Post: 04-05-2017, 03:54 AM
  2. If multiple conditions exist, then combine text fields
    By shilburn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-01-2014, 01:11 PM
  3. Sort, Adding Sort Fields
    By kestefon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2013, 02:56 AM
  4. [SOLVED] Returning most recent dates with conditions where some fields are blank
    By connmtc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-27-2013, 06:06 PM
  5. How to Disable automatic fields in pivot table like total and count on fields
    By anushka in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2009, 07:53 AM
  6. Sort on Protected Fields
    By PR in forum Excel General
    Replies: 4
    Last Post: 11-08-2005, 06:00 PM
  7. Replies: 3
    Last Post: 01-17-2005, 08:06 AM

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