+ Reply to Thread
Results 1 to 5 of 5

Finding distinct values across multiple columns - FREQUENCY array?

  1. #1
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Finding distinct values across multiple columns - FREQUENCY array?

    Hi guys

    I'm having trouble getting my head around array formulae, but I'm pretty sure that's what I need here.

    I basically have a sheet with data in the following format:

    Dept Agent Date
    AM - hjhjlk Michael Jones 04/03/2014
    AM - uyuiyi John Smith 05/03/2014
    AM - hjhjlk Michael Jones 05/03/2014
    AM - uyuiyi Mark Johnson 06/03/2014
    JS - jhkkjhi Pierre Ginola 06/03/2014
    AM - hjhjlk Michael Jones 06/03/2014
    AM - hjhjlk Anne Frank 06/03/2014
    JS - ghgjh Julio Ramirez 06/03/2014

    What I need to do is count the number of distinct agents for a department (based only on the first two letters of the department) for a particular time period.
    So, for instance:

    Date range 04/03/14-06/03/14
    AM would return 4
    JS would return 2

    Date range 04/03/14-05/03/14
    AM would return 2
    JS would return 0

    I'm almost certain it's going to require an array formula using the FREQUENCY function, but despite trying a number of things I'm struggling to adapt other formulas I've found online to meet my requirements.

    Any help would be massively appreciated.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Finding distinct values across multiple columns - FREQUENCY array?

    Hi.

    Assuming that the table as you give it is in A1:C9 (with headers in row 1), and that you put your start date (e.g. 04/03/2014), end date (e.g. 06/03/2014) and two-letter department (e.g. AM) in E1, F1 and G1 respectively, this array formula**:

    =SUM(IF(FREQUENCY(IF(LEFT(A2:A9,2)=G1,IF(C2:C9>=E1,IF(C2:C9<=F1,MATCH(B2:B9,B2:B9,0)))),ROW(B2:B9)-MIN(ROW(B2:B9))+1),1))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,615

    Re: Finding distinct values across multiple columns - FREQUENCY array?

    edited: I have not read description well enough, so ofered solution was wrong.
    Last edited by Kaper; 01-12-2015 at 08:05 AM.
    Best Regards,

    Kaper

  4. #4
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: Finding distinct values across multiple columns - FREQUENCY array?

    Thanks XOR, works just as required!

    Unfortunately it's looking like it'll be too slow given the amount of data I have (10k+ rows), so I'll probably need to go down the VBA route, but hopefully this helps someone else!

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Finding distinct values across multiple columns - FREQUENCY array?

    You're welcome!

    Yes, unfortunately, with a dataset of such size this construction is likely to struggle.

    Good luck with the VBA!

    Regards

+ 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] Finding common values over multiple columns
    By olgratefuldead in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-30-2014, 12:55 AM
  2. Finding distinct values within a single string
    By balki42 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-25-2013, 06:39 AM
  3. Replies: 0
    Last Post: 08-03-2012, 04:31 PM
  4. Replies: 1
    Last Post: 03-02-2011, 04:14 PM
  5. Finding frequency and repetition of values in cells in a row
    By Adam14 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-25-2011, 05:13 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