+ Reply to Thread
Results 1 to 14 of 14

Combining countif and frequency functions to count uniq

Hybrid View

  1. #1
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Combining countif and frequency functions to count uniq

    Dear Gents,

    Could you please help me with the below?.


    I'm trying to merge the countif and frequency functions to find the unique values at various times.

    For example, I have the time in one sheet, and in another, I have the range time and the column where I would like to count the total unique.

    Sheet1 (time)
    Time
    000000
    000500
    001000
    001500
    002000

    Sheet2 (database)
    19 000000
    4 000003
    19 000500
    19 000501
    4 000502
    19 000504
    1 000505
    2 001000
    19 001005
    3 001010
    4 001015
    8 001020
    20 001500

    Desired output

    Time
    000000 1
    000500 2
    001000 4
    001500 5

    I have tried the below formula, but for some reason, it doesn't work, and also, it took a long time as my database has more than 40k rows
    =SUMPRODUCT((data!BY:BY=VIBRO!B4)*(ROW(data!BY:BY)-ROW(data!$BY$2)+1=MATCH(data!BY:BY&data!T:T,data!BY:BY&data!T:T,0)))

    Appreciate your support
    Attached Files Attached Files
    Last edited by jiam912; 08-28-2022 at 11:23 AM. Reason: To attach example file

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,972

    Re: Combining countif and frequency functions to count uniq

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Re: Combining countif and frequency functions to count uniq

    Hi Ali, thanks a lot for the advice.. I have attached the example file

  4. #4
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,997

    Re: Combining countif and frequency functions to count uniq

    What is the logic of counting?

    Why 4 for the last 2 results?


    for me is 6

  5. #5
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Re: Combining countif and frequency functions to count uniq

    Hi, many thanks for answering.
    The logic of counting unique values in column P, e.g. in the range rows 238 to 355, column Q time 001002 to 001459. I want to count only the unique values in this range of time.. values 10,12,19,25 are repeated multiple times; the purpose is to count unique values.. that's why I have 4 as result..

    Using Sh2 columnB sheet I would to count the unique values from Sh1 columnQ ~ count unique column P

  6. #6
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,997

    Re: Combining countif and frequency functions to count uniq

    Sh2

    =SUM(IF(FREQUENCY(IF('Sh1'!Q$2:Q$355<='Sh2'!$B3,'Sh1'!$P$2:$P$355),'Sh1'!$P$2:$P$355),1))

    control +shift +enter

    copy down


    but is 6

  7. #7
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Re: Combining countif and frequency functions to count uniq

    Dear Caracalla,
    The purpose is to check the unique values in the range of time (bins), using <='Sh2'!$B3 seems to don't work. .. Is there any way just to count the values in the range of the time for each time in Sh2.
    Thanks a lot for your help.
    Last edited by jiam912; 08-28-2022 at 01:46 PM.

  8. #8
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Re: Combining countif and frequency functions to count uniq

    Per example
    Capture.PNG.. see the errors,, Kindly, I need to grep the values in the lapse of time according to the bins and count only the unique numbers..

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,984

    Re: Combining countif and frequency functions to count uniq

    This proposal employs a lookup table (T2:T5), a helper column and Power Pivot.
    1. Cells X2:X5 are populated with 0, 500, 1000 and 1500
    2. The helper column (Time Range) is populated using: =AGGREGATE(15,6,T$2:T$5/(T$2:T$5>=Q2),1)
    3. Select any cell in columns P:R and from the Insert tab select Pivot Table
    4. Select the Add this data to the Data Model check box and then select location for pivot table
    5. Drag the Time Range field into the Rows area and Code into the Values area
    6. Change the Summarize Values By of the Code field to Distinct Count
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  10. #10
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Smile Re: Combining countif and frequency functions to count uniq

    I am grateful for your help. It works perfectly..

  11. #11
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Re: Combining countif and frequency functions to count uniq

    Quote Originally Posted by JeteMc View Post
    This proposal employs a lookup table (T2:T5), a helper column and Power Pivot.
    1. Cells X2:X5 are populated with 0, 500, 1000 and 1500
    2. The helper column (Time Range) is populated using: =AGGREGATE(15,6,T$2:T$5/(T$2:T$5>=Q2),1)
    3. Select any cell in columns P:R and from the Insert tab select Pivot Table
    4. Select the Add this data to the Data Model check box and then select location for pivot table
    5. Drag the Time Range field into the Rows area and Code into the Values area
    6. Change the Summarize Values By of the Code field to Distinct Count
    Let us know if you have any questions.
    Hi JeteMc.. Kindly, can you let me know how you added Distinct Count?

  12. #12
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,984

    Re: Combining countif and frequency functions to count uniq

    Perhaps this tutorial will explain better than I did in post #9: https://www.excelcampus.com/pivot-ta...-pivot-tables/
    Scroll down to the section titled "Solution # 2 - Using Power Pivot".
    Let us know if you have any questions.

  13. #13
    Registered User
    Join Date
    02-12-2019
    Location
    usa
    MS-Off Ver
    2016
    Posts
    44

    Re: Combining countif and frequency functions to count uniq

    Hi JeteMC,
    Thanks a lot for the tutorial and advice,.. Highly appreciate your support.

    Is there any excel formula that can do exactly same function that pivot-table.

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,984

    Re: Combining countif and frequency functions to count uniq

    By adding another helper column:
    1. The additional helper column (S) is populated using: =COUNTIFS(P$2:P2,P2,R$2:R2,R2)=1
    2. Cells Y4:Y7 are populated with the bins
    3. Cells Z4:Z7 are populated using: =COUNTIFS(R$2:R$355,Y4,S$2:S$355,TRUE)
    Let us know if you have any questions.
    Attached Files Attached Files

+ 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] Count uniq orders
    By alexxl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-05-2020, 12:15 PM
  2. [SOLVED] Getting wrong results for frequency function and countif functions
    By KurtBliss in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-13-2015, 06:39 PM
  3. Combining IF COUNTIF AND functions
    By sbala in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-11-2015, 12:47 PM
  4. Combining Frequency and Countif Formulas
    By kiokeefe in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-19-2012, 08:34 AM
  5. Replies: 0
    Last Post: 05-04-2011, 06:26 PM
  6. Combining Functions Countif & Frequency
    By vagabond in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-10-2010, 08:04 AM
  7. combining countif and mid or right functions
    By Charles Woll in forum Excel General
    Replies: 5
    Last Post: 07-09-2005, 08:05 PM

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