+ Reply to Thread
Results 1 to 12 of 12

Using sum if frequency to count unique values based on certain criteria

  1. #1
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Using sum if frequency to count unique values based on certain criteria

    Hi All,

    I am having a problem with the below formula I have entered in Sheet 2 of my workbook.
    Where "D6 = Agent Name" "D8 = Criteria 1" "D9 = Criteria 2" "D10 = Criteria 3" "D11 = Criteria 4"

    =SUM(IF(FREQUENCY(IF('Sheet 1'!$C:$C<>"""",IF('Sheet 1'!$G:$G=D8,IF('Sheet 1'!$H:$H=D6,MATCH(""~""&'Sheet 1'!$C:$C,'Sheet 1'!$C:$C&"""",0)))),ROW('Sheet 1'!$C:$C)-ROW('Sheet 1'!$C$2)+1),1))+SUM(IF(FREQUENCY(IF('Sheet 1'!$C:$C<>"""",IF('Sheet 1'!$G:$G=D9,IF('Sheet 1'!$H:$H=D6,MATCH(""~""&'Sheet 1'!$C:$C,'Sheet 1'!$C:$C&"""",0)))),ROW('Sheet 1'!$C:$C)-ROW('Sheet 1'!$C$2)+1),1))+SUM(IF(FREQUENCY(IF('Sheet 1'!$C:$C<>"""",IF('Sheet 1'!$G:$G=D10,IF('Sheet 1'!$H:$H=D6,MATCH(""~""&'Sheet 1'!$C:$C,'Sheet 1'!$C:$C&"""",0)))),ROW('Sheet 1'!$C:$C)-ROW('Sheet 1'!$C$2)+1),1))+SUM(IF(FREQUENCY(IF('Sheet 1'!$C:$C<>"""",IF('Sheet 1'!$G:$G=D11,IF('Sheet 1'!$H:$H=D6,MATCH(""~""&'Sheet 1'!$C:$C,'Sheet 1'!$C:$C&"""",0)))),ROW('Sheet 1'!$C:$C)-ROW('Sheet 1'!$C$2)+1),1))

    The data this looks into in Sheet 1 is as follows...

    Column C Column D Column E Column F Column G Column H Column I
    Company 1 Initials Phone Call Agent Name Date + Time
    Company 2 Initials Phone Call Agent Name Date + Time
    Company 3 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 4 Initials Phone Call Agent Name Date + Time
    Company 5 Initials Phone Call 2 Agent Name Date + Time
    Company 6 Initials Phone Call Agent Name Date + Time
    Compnay 7 Initials Phone Call 2 Agent Name Date + Time
    Compnay 7 Initials Phone Call 2 Agent Name Date + Time

    Column C - Company
    Column D - Initials
    Column E and F are blank
    Column G - Phone Call Type
    Column H - Agent Name
    Column I - Date and Time Stamp

    I am using the formula to calculate how many unique companies (Column C) have been contacted by agent (Column H). This also needs to be calculated against the criteria in Column G. There are hundreds of records and they are all mixed in together. Column G can have many different fields so I only want to pick out the phone calls which are labelled Phone Call, Phone Call 2, Phone Call 3, and Phone Call 4. Can this be simplified into "Phone Call*" possibly? Based on the above data the answer is 7 after pulling this data out in a separate sheet the following formula tells me 7 records but has no criteria to reference =SUM(IF(FREQUENCY(MATCH(C2:C15,C2:C15,0),MATCH(C2:C15,C2:C15,0))>0,1)) the above formula I am needing help with returns 13?

    Please can anyone make sense of what I am saying and help me out please!
    Attached Files Attached Files
    Last edited by Matthew_Smith86; 07-07-2015 at 01:30 PM.

  2. #2
    Registered User
    Join Date
    03-27-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Using sum if frequency to count unique values based on certain criteria

    Sorry, posted in incorrect thread.
    please ignore my reply.
    Last edited by Sum; 07-07-2015 at 09:50 AM.

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

    Re: Using sum if frequency to count unique values based on certain criteria

    Hi and welcome to the forum.

    First off, I think you should know that the formula you give has to be probably the most resource-heavy single formula I think I have ever seen.

    That formula is being forced to calculate, at a rough estimate, nearly 21 million cells before arriving at a result. That's an absolutely incredible amount for a single formula.

    The overriding reason is your use of entire column references. Do you really have data extending all the way down to row one million-plus?

    If not, I strongly recommend that you either choose a suitably low, though sufficient, upper bound for the end row being referenced or, even better, make your ranges dynamic, such that they automatically adjust as your data expands or contracts.

    The point is that array formulas calculate over all cells passed to them. And that applies whether those additional cells are technically beyond the last-used cells in those ranges or not.

    With some functions, e.g. COUNTIF(S)/SUMIF(S), you can get away with referencing entire columns with no detriment to performance, though not with functions which operate over arrays, such as AGGREGATE, SUMPRODUCT, and any construction requiring CSE.

    Regards
    Click * below if this answer helped

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

  4. #4
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Re: Using sum if frequency to count unique values based on certain criteria

    Thank you for your reply. It doesn't necessarily need to be that thorough, I could probably get away with 5000 rows as long as I did a new workbook for each year of data.

  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: Using sum if frequency to count unique values based on certain criteria

    Thanks.

    Where are your results supposed to go? Have you set-up a table ready to house them? If not, could you do so and re-attach your workbook?

    Regards

  6. #6
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Re: Using sum if frequency to count unique values based on certain criteria

    Hi, thanks again for taking a look into this. I have uploaded the amended version with the "TOTALS" tab.

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

    Re: Using sum if frequency to count unique values based on certain criteria

    So you're just looking for formulas to replace your existing ones next to all the Unique Contacts entries? That is, improved, more efficient versions, but the results you're currently getting are nevertheless correct?

    Regards

  8. #8
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Re: Using sum if frequency to count unique values based on certain criteria

    Well Attempt 1, Contact 1, Contact 2, Contact 3 and Contact 4 all work fine for what I need, it is the unique contacts that isn't working correctly. I want that to tell me how many unique companies have been contacted by agent, for example 1 company could have 3 contact 1's, 4 contact 2's, 5 contact 3's and 1 Contact 4, that would suggest we have made 13 contacts to 1 company and this could be across 10 companies for example, which would be 130 contacts but I want it to tell me that it has been 10 unique companies contacted. I hope this makes sense, and thanks again.

  9. #9
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Re: Using sum if frequency to count unique values based on certain criteria

    I have just re-read your reply, no the answers I believed to be correct aren't correct. It is calculating a few more than it should. For example Agent 5 should be recording 11 but instead records 13.

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

    Re: Using sum if frequency to count unique values based on certain criteria

    So for cell E23 you should be using:

    =SUM(IF(FREQUENCY(IF('Sheet 1'!$H$2:H200=$D$16,IF(ISNUMBER(MATCH('Sheet 1'!$G2:$G200,$D$17:$D$21,0)),MATCH("~"&'Sheet 1'!$C2:$C200,'Sheet 1'!$C2:$C200&"",0))),ROW('Sheet 1'!$C2:$C200)-ROW('Sheet 1'!$C$2)+1),1))

    Note the upper row reference!

    Regards

  11. #11
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Re: Using sum if frequency to count unique values based on certain criteria

    That works perfectly, thank you so much for your time, effort and help it is very much appreciated.

    I do have one other question to ask. Is it possible to incorporate a date range into this. The date stamp in the data is column "I" and I would like the user to be able to select a date range by entering the start date in "E1" and end date in "E2" on the "TOTALS" tab. I can get all the other formulas to work on this basis but don't want to fiddle with the Formula in "E23" too much after the troubles I have had.

  12. #12
    Registered User
    Join Date
    07-07-2015
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    9

    Re: Using sum if frequency to count unique values based on certain criteria

    I would like the result to include the start date and end date if that makes a difference to the formula needed, thank you in advance.
    Last edited by Matthew_Smith86; 07-08-2015 at 05:35 AM.

+ 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. Count unique values based on multiple criteria
    By Jonathan11235 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 05-19-2015, 10:02 PM
  2. [SOLVED] Count unique values based on criteria without using array
    By jonpaulson in forum Excel General
    Replies: 14
    Last Post: 10-10-2014, 06:30 PM
  3. [SOLVED] Count unique values in columns based on 2 criteria
    By t83357 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-12-2013, 04:33 PM
  4. Count unique values based on several criteria
    By evilgrin in forum Excel General
    Replies: 2
    Last Post: 10-10-2010, 03:50 PM
  5. Count unique values based on matching criteria
    By gromitw in forum Excel General
    Replies: 9
    Last Post: 01-10-2007, 08:59 AM

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