+ Reply to Thread
Results 1 to 8 of 8

Spill range with COUNTIFS of unique rows

  1. #1
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Spill range with COUNTIFS of unique rows

    Hi,

    I have a table of data (column A, B and C) which contains multiple duplicate rows. I want to create a results column M that has COUNTIFS results with criteria for each row in the table, counted as if each of the rows were unique, without duplicates.

    I am able to do this in an indirect way, by first creating a spill range (column F, G and H) containing unique values, and then performing the COUNTIFS by referencing this spill range. See results in column K of the attached workbook.

    But when I try to create the spill range inside the criteria_range of the COUNTIFS formula, I get #VALUE! errors because COUNTIFS don't accept arrays.

    Does anybody have a solution for this? There's also an OR argument inside the formula I am using, and I want to create the results with a spilled range.

    Best regards,
    Marbleking
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Spill range with COUNTIFS of unique rows

    No you there is no such way with countifs. In this case you need the helper columns.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Spill range with COUNTIFS of unique rows

    FAR too many rows! It is impossible to do ANY manual checking.


    I do not fully understand what you want, so I deleted most of the rows (to align with Forum guidleines). I still don't quite understand your "correct" answers. Please manually calculate what you expect to see for the 14 remaining rows... or confirm that the values are correct (and then explain why the 3 highlighted rows are all 2).
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Spill range with COUNTIFS of unique rows

    Hi Glenn,

    Thanks for deleting rows I should have deleted myself before sending the workbook.

    The values that are seen in column K are correct.

    I have added a column O where the calculations have been performed in the traditional "copy the formula down" way.

    This is the formula:

    =COUNTIFS($F$2:$F$7,"<="&$A2;$G$2:$G$7,"<="&$B2;$H$2:$H$7,">="&$A2)+COUNTIFS($F$2:$F$7,"<="&$A2;$G$2:$G$7,"<="&$B2;$H$2:$H$7,"")


    I have the unique rows from the data table (column A, B and C) in the intermediate table (columns F, G and H). I want to count how many rows in the intermediate table that corresponds to the criteria made up of values from each row in the data table. For the first row in the data table, that will be "how many rows (with its three columns) in the intermediate table corresponds to "<="&$A2 AND "<="&$B2 AND (">="&$A2 OR "") from that row in the data table.

    The formula I need will accomplish this without having to use the intermediate formula, but will instead "create a table of unique rows from the data table, and then apply criteria to each of the columns", while spilling the results. I don't think the COUNTIFS will be able to do that, but perhaps some other functions from O365.

    Regards,
    Marbleking
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Spill range with COUNTIFS of unique rows

    With Power Query.

    See the attached file.

    Please Login or Register  to view this content.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

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

    Re: Spill range with COUNTIFS of unique rows

    try

    =LET(z,Table1,BYROW(z,LAMBDA(r,ROWS(UNIQUE(FILTER(z,(INDEX(z,,1)<=INDEX(r,,1))*(INDEX(z,,2)<=INDEX(r,,2))*(INDEX(z,,3)>=INDEX(r,,1))))))))
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Spill range with COUNTIFS of unique rows

    Thanks all, I'll have use for both the PQ version sometime, as well as the dynamic array formula. As of now, the BYROW and LAMBDA functions aren't available in my O365 at work, unfortunately. So if it's possible to modify it to something that doesn't use these, that would be great.

    Regards,
    Marbleking

  8. #8
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Spill range with COUNTIFS of unique rows

    Hi Bo_Ry,

    Your fine solution doesn't work in my version of Excel since BYROW and LAMBDA is in beta. Do you have a modified version of the formula that doesn't use beta functions? That'd be great!

    Regards,
    Marbleking

+ 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] Spill Range Across Rows and Columns
    By dluhut in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2021, 09:20 AM
  2. [SOLVED] Countifs returning #SPILL or #VALUE error
    By Brapp2Smokin in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-13-2021, 10:25 PM
  3. Using UNIQUE function with table ranges, cant avoid #SPILL! error
    By Lacaycer in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-22-2020, 09:38 AM
  4. Replies: 8
    Last Post: 08-29-2020, 09:25 AM
  5. Replies: 14
    Last Post: 03-19-2017, 08:11 AM
  6. using countifs to track unique values over a date range
    By msnyderxc in forum Excel General
    Replies: 1
    Last Post: 03-21-2014, 11:48 AM
  7. Replies: 2
    Last Post: 06-04-2012, 12:22 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