+ Reply to Thread
Results 1 to 12 of 12

AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

  1. #1
    Registered User
    Join Date
    08-23-2020
    Location
    Adelaide, Australia
    MS-Off Ver
    2016
    Posts
    6

    AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Hey people!

    Is it possible to COUNTIFS Column C contains "Y" OR Column D contains "Y". Therefore COUNT should = 2

    Is it possible to also AVERAGEIFS the Age if Column C OR Column D contains Y? Therefore average should = 37.5.

    I have a spreadsheet that contains thousands of rows and hundreds of columns so I usually select my columns in formulas like this: $C:$C vs $C$2:$C$35
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,461

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Countif:

    Please Login or Register  to view this content.
    Average

    Please Login or Register  to view this content.
    Quang PT

  3. #3
    Registered User
    Join Date
    08-23-2020
    Location
    Adelaide, Australia
    MS-Off Ver
    2016
    Posts
    6

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Thanks Bebo.
    Perhaps I should have been more specific.
    On the actual workbook I work from:
    Age is located in column DG
    FIRST is located in column V
    SECOND is located in column JA

    Therefore the formula would need to select each column individually $C$C AND $D$D rather than as a whole $C$2:$D$35 otherwise I would be selecting from $V to $JA..

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,461

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Is there case of "Y" appear in the same row? (same patient with "Y" in both first and second)

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,461

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Assum "Y" appear only one in both column, try:

    Count:
    Please Login or Register  to view this content.
    Average:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Please try

    Count
    =SUMPRODUCT(--(MMULT(--(C2:D9="Y"),{1;1})>0))

    Sum
    =SUMPRODUCT(B2:B9,--(MMULT(--(C2:D9="Y"),{1;1})>0))

    average
    =Sum/Count

    or Faster with Helper column

    C2 =C2&D2
    then
    =COUNTIFS(E2:E9,"Y*")
    and
    =AVERAGEIFS(B2:B9,E2:E9,"Y*")
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-15-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    c2:d9 requires contiguous columns but I think the solution can be adjusted

  8. #8
    Registered User
    Join Date
    09-15-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Assuming
    Column C and D are, in practice, not contiguous so solution uses them separately
    We want to avoid row references in formula because there are thousands of rows
    We want to treat correctly the cases where there are 2 Y's and where there are no Y's.
    I added Patient 3 and 4 in the attachment to cover these two cases.

    Does this work?

    This requires a helper column, which I put in Column E.
    Also needs to put a formula in each cell but we avoid row references

    In each cell of Helper Column put =OR([at]C:C="Y",[at]D:D="Y")
    The [at] stands for the "at" sign - it's in the attachment

    Then average is written simply as
    =SUMIF(E:E,TRUE,B:B)/COUNTIF(E:E,TRUE)
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-15-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    How does this get marked as solved? There are several answers which seem to work one way or the other.

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

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    It's not your thread, so not your call.
    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.

  11. #11
    Registered User
    Join Date
    09-15-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    Thank you, that helps.

    Supplementary question - How long do we have to post solutions for threads not yet marked solved? If this thread were open (not marked solved) for like 6 months, is it still OK? I'd like to work on another solution to this thread. Thanks in advance.
    Last edited by Don Toto; 11-09-2020 at 08:53 PM.

  12. #12
    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,482

    Re: AVERAGEIFS AGE & COUNTIFS Column C contains Y OR column D contains Y

    You can post a proposed solution to ANY thread, whether marked as solved or not. However, if a thread is marked as solved, the OP is less likely to see and respond to your additional help.

+ 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. COUNTIFS( where one criteria compares a column to another column)
    By corecomps in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-26-2019, 02:02 PM
  2. Using possible conditional averageifs and countifs.
    By Noah101 in forum Excel General
    Replies: 3
    Last Post: 09-12-2017, 11:26 PM
  3. Countifs - date column by month & second column text value
    By Chelrie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-27-2016, 04:33 PM
  4. averageifs for both row and column.
    By cgs45 in forum Excel General
    Replies: 4
    Last Post: 05-30-2014, 02:41 AM
  5. [SOLVED] Averageifs Countifs function
    By vandan_tanna in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-16-2013, 11:14 AM
  6. Countifs or AverageIfs
    By dreicer_Jarr in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-13-2013, 02:44 AM
  7. Countifs and Averageifs
    By tradergreg in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-08-2011, 07:20 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