Results 1 to 4 of 4

Formula for conditional distinct count on very large ranges

Threaded View

  1. #4
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Formula for conditional distinct count on very large ranges

    it is even not optimization because the speed will be very close but
    =SUMPRODUCT(($C$3:$C$20=F3)*($B$3:$B$20<>"");1/COUNTIFS($C$3:$C$20;$C$3:$C$20&"";$B$3:$B$20;$B$3:$B$20&""))
    I have tested several methods
    SUMPRODUCT(Cond1*Cond2)
    SUMPRODUCT(Cond1;Cond2)
    SUM(Cond1*Cond2) array formula

    Generally SUMPRODUCT(Cond1;Cond2) is favorite.

    But in this case FREQUENCY is winner
    =SUM(INDEX(($C$3:$C$5002=F3)*($B$3:$B$5002<>"")/COUNTIFS($C$3:$C$5002,$C$3:$C$5002&"",$B$3:$B$5002,$B$3:$B$5002&""),)) 5,078125
    =SUMPRODUCT(($C$3:$C$5002=F3)*($B$3:$B$5002<>""),1/COUNTIFS($C$3:$C$5002,$C$3:$C$5002&"",$B$3:$B$5002,$B$3:$B$5002&"")) 5,050781
    =IFERROR(SUM(IF(FREQUENCY(IF($C$3:$C$5002=F3,MATCH($B$3:$B$5002,$B$2:$B$5002,0)),ROW($B$3:$B$5002)-ROW($B$3)+1),1)),"") 0,0078125

    =SUM(INDEX(($C$3:$C$9002=F3)*($B$3:$B$9002<>"")/COUNTIFS($C$3:$C$9002,$C$3:$C$9002&"",$B$3:$B$9002,$B$3:$B$9002&""),)) 17,1875
    =SUMPRODUCT(($C$3:$C$9002=F3)*($B$3:$B$9002<>""),1/COUNTIFS($C$3:$C$9002,$C$3:$C$9002&"",$B$3:$B$9002,$B$3:$B$9002&"")) 16,74609
    =IFERROR(SUM(IF(FREQUENCY(IF($C$3:$C$9002=F3,MATCH($B$3:$B$9002,$B$2:$B$9002,0)),ROW($B$3:$B$9002)-ROW($B$3)+1),1)),"") 0,015625

    =SUM(INDEX(($C$3:$C$18002=F3)*($B$3:$B$18002<>"")/COUNTIFS($C$3:$C$18002,$C$3:$C$18002&"",$B$3:$B$18002,$B$3:$B$18002&""),)) 67,43359
    =SUMPRODUCT(($C$3:$C$18002=F3)*($B$3:$B$18002<>""),1/COUNTIFS($C$3:$C$18002,$C$3:$C$18002&"",$B$3:$B$18002,$B$3:$B$18002&"")) 69,51172
    =IFERROR(SUM(IF(FREQUENCY(IF($C$3:$C$18002=F3,MATCH($B$3:$B$18002,$B$2:$B$18002,0)),ROW($B$3:$B$18002)-ROW($B$3)+1),1)),"") 0,03125

    However
    FREQUENCY could be extracted
    array formula
    Formula: copy to clipboard
    =IFERROR(SUM(--IF($C$3:$C$18002=F3,MATCH($B$3:$B$18002,$B:$B,)=ROW($B$3:$B$18002))),"")
    is shorter and power also

    =SUM(INDEX(($C$3:$C$18002=F3)*($B$3:$B$18002<>"")/COUNTIFS($C$3:$C$18002,$C$3:$C$18002&"",$B$3:$B$18002,$B$3:$B$18002&""),)) 66,38672
    =SUMPRODUCT(($C$3:$C$18002=F3)*($B$3:$B$18002<>""),1/COUNTIFS($C$3:$C$18002,$C$3:$C$18002&"",$B$3:$B$18002,$B$3:$B$18002&"")) 65,95703
    =IFERROR(SUM(IF(FREQUENCY(IF($C$3:$C$18002=F3,MATCH($B$3:$B$18002,$B$3:$B$18002,0)),ROW($B$3:$B$18002)-ROW($B$3)+1),1)),"") 0,0234375
    =IFERROR(SUM(--IF($C$3:$C$18002=F3,MATCH($B$3:$B$18002,$B$3:$B$18002,0)=ROW($B$3:$B$18002)-ROW($B$3)+1)),"") 0,02734375
    =IFERROR(SUM(--IF($C$3:$C$18002=F3,MATCH($B$3:$B$18002,$B:$B,)=ROW($B$3:$B$18002))),"") 0,0234375
    Last edited by BMV; 11-22-2020 at 10:15 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count distinct values based on criteria (large data)
    By ifulao in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-02-2020, 05:31 AM
  2. Formula for distinct count in Data Model excluding 0s
    By Abell in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-07-2019, 11:23 AM
  3. [SOLVED] How to craft a copy down formula for distinct, separate ranges.
    By Coyote_e in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-15-2019, 09:34 PM
  4. [SOLVED] Count of distinct values between two date ranges
    By HKPHOOY in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 03-01-2018, 02:39 PM
  5. [SOLVED] Count Conditional Distinct Values
    By Gos-C in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-10-2013, 05:41 AM
  6. Formula - Count distinct / Countif??
    By Africa in forum Excel General
    Replies: 3
    Last Post: 02-29-2012, 11:24 AM
  7. Count frequency of set hour ranges from large list of times
    By samchargers09 in forum Excel General
    Replies: 11
    Last Post: 02-26-2010, 07:14 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