How do I count the unique value pairs in two columns of a table?

I have a table (Table 2) that is populated with data from an imported .csv file. On table 1 I need to count the unique value pairs in two columns of Table 2.
Here's what I have:
Date                                        Person
7/10/2011                         A
7/12/2011                         W
7/12/2011                         X
7/12/2011                         X
7/12/2011                         X
7/12/2011                         Z
7/14/2011                         Z
7/15/2011                 X
7/16/2011                         Z
I'm focusing on person "X" and can easily count how many days that person shows up but what I want is to see on how many unique days that person shows up.
Here's the result I'm looking for (Person "X" shows up on 2 different days - 3 times on 7/12/2011 and once on 7/15/2011):
X                    2
I can't seem to find a function that allows me to do that. I also am not allowed to modify Table 2 so that leaves me to come up with a solution on Table 1.
Any ideas would be greatly appreciated.

Hi John,
Not being allowed to modify Table 2 is a minor inconvenience. Just copy (using a formula) the necessary two columns onto Table 1.
Yellow columns may be hidden. The procedure progresses from left to right. All formulas are entered into row 2 then filled down that column to the end of the table. The table must be as long as the list in column A of Table 2.
A2: =Table 2::A
Fill right to column B.
Fill both columns down as far as needed.
I've used actual Date and Time values in column A, formatted to show only the Date part, but the technique will work with text in these cells, provided all cells representing the same 'date' have exactly the same content.
C2: =A&B
This concatenates the contents of each row of columns A and B into a single text string.
D2: =COUNTIF($C$2:C2,C)
This counts the number of occurrences of the Date&Name string on the current row from the first regular cell in column C (C2) to the current cell.
E2: =IF(COUNTIF($B$2:B2,B)=1,MAX($E$1:E1)+1,"")
This constructs the index of first occurrences of each name, in the order they first occur. The index is used by LOOKUP in column F.
F2: =IF(ROW()-1>MAX(E),"",LOOKUP(ROW()-1,$E,$B))
This uses the index value created in E as a search-for value to extract a single copy of the names in column B. The result is a list of all distinct names in the list. Note that spelling differences will be counted as distinct names.The IF statement stops the listing when the last distinct name is extracted.
G2: =IF(LEN(F)>0,COUNTIFS($B,"="&F,$D,"=1"),"")
This counts the number of 'first occurrences of distinct Date & Name strings for each name on the list (ie. the number of distinct dates on which each name appears in the original list).
All of the functions used are described, with at least one example for each, in the iWork formulas and Functions User Guide. You can download the guide, and the Numbers '09 User Guide, via the Help menu in numbers.
Regards,
Barry

Similar Messages

  • How do I count the unique text entries in a column

    I want to count thenumber of unique text entries in a column how do I do that?

    Or, if you will need to do this on different documents, you can copy this script into AppleScript Editor, select the cells in whichever document you are working on, and run. No need to set up the formulas and extra column again.
    SG
    --select range of cells, run; provides count of distinct values
    tell application "Numbers" to tell the front document to tell active sheet
              set selectedTable to (the first table whose class of selection range is range)
              tell selectedTable to tell the selection range
                        set distinctValues to {}
                        repeat with aCell in its cells
                                  tell aCell
                                            if its value is not in distinctValues then ¬
                                                      copy its value to the end of distinctValues
                                  end tell
                        end repeat
                        return count of distinctValues
              end tell
    end tell
    --end of script

  • How to get count of unique values of column B for each unique value of column A in Excel 2010?

    I have an excel sheet containing 72,000 rows in Excel 2010, column A is "site name", column B is category. I want a result that shows number of sites for each category.
    Column A Column B
    site 1 Category 1
    Site 1 Category 1
    Site 2 Category 1
    site 3 Category 2
    site 3 Category 2
    site 4 Category 2
    site 5 Category 2
    I want this result:
    Category 1    2
    Category 2    3
    I tried some formula in a 3rd column and created a pivot table on that column, but it did not give me the result i want.
    Any one has an idea ? what is the easiest way to achieve this?
    Appreciate any pointer

    I tried both formula referenced in these two post (I think they are a little simpler than the one above):
    http://stackoverflow.com/questions/11876238/simple-pivot-table-to-count-unique-values
    http://stackoverflow.com/questions/18898138/pivot-table-count-unique-values-excel-2010
    They both worked! and I got the result for my 72,000 rows!
    Thanks for your help!

  • Count the number of records between two key values (BTREE)

    How can I count the number of keys between two values?
    I'm using python driver, and BTREE access method.
    ====>
    ideally what I want is to average a whole time-series data set (the intervals can change) to a given number of points. The keys are the time stamps and the values are the data that needs to be averaged. I need to count the number of records between two time stamps so that I can divide that number by the number of points i need, and average the data. What is the best way to do this?  Or should I just keep the intervals for the time stamp constant and use RECNO access method?
    Thank you
    (first post btw.. and why aren't there many people in stackoverflow who answer Berkeley DB questions?)

    BDB is an embedded db and it does not have any internal counters or statistics that you could grap to use for this.    You will need to do it manually.
    You can create a cursor, grap the records you want, each time you get the next record you bump a counter.
    If you are using RECNO, you can use a cursor to get the record number of the record (DB_GET_RECNO), and if all you data is in
    sequentail records with no missing records you can figure out the total count by take last rec # - initial rec # + 1 to get a total count.
    If you switch over to the SQL API, you can issue a SQL query to give you a count.  Select count(*) Where .......
    Since you have to grab the data anyway, then best may be to count records as you go along.
    thanks
    mike

  • How can I reference the last value in a column?

    How can I reference the last value in a column? For example, today I want the value of A1 to appear in another cell. Tomorrow, I will add a row and want to reference A2, next day A3, and so forth.

    Now I got it:
    =OFFSET(A1,COUNT(A)-1,0)

  • How do you count the multiple columns of a field in a table

    How do you count the multiple columns of a field in a table

    Hi,
    4396bf34-e890-4202-a6b0-4e08c9ff0e89 wrote:
    How do you count the multiple columns of a field in a table
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    "Field" isn't a standard database term.  Some people say "field" when they mean "column", but I don't think that's what you mean ("How do you count the multiple columns of a column ..").  Do you want to know how many times a column is used (as opposed to NULL), or the number of different values in a column?  You really need to show what you want.

  • How can i count the word in a cell.

    Dear Experts,
    i want to count the word in cell how can i do this ?
    Isthere any function ?
    plz give logic or command.

    You can ty :
    SQL> var text varchar2(50)
    SQL> exec :text := 'How do I count the number of words in my cell?'
    PL/SQL procedure successfully completed.
    SQL> select text,
      2         sum(case when substr(text,rownum,1)=' '
      3                       and substr(text,rownum-1,1)!=' '
      4                  then 1
      5                  else 0 end) nb_word
      6  from (select rownum,:text||' ' text,length(:text) ln from dual)
      7  connect by level <= ln+1
      8  group by text
      9  /
    TEXT
       NB_WORD
    How do I count the number of words in my cell?
            11
    SQL>  exec :text := 'How     do I count the number of words in my   cell?    '
    BEGIN :text := 'How     do I count the number of words in my   cell?    '; END;
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 1
    SQL> var text varchar2(1000)
    SQL> exec :text := 'How     do I count the number of words in my   cell?    '
    PL/SQL procedure successfully completed.
    SQL> select text,
      2         sum(case when substr(text,rownum,1)=' '
      3                       and substr(text,rownum-1,1)!=' '
      4                  then 1
      5                  else 0 end) nb_word
      6  from (select rownum,:text||' ' text,length(:text) ln from dual)
      7  connect by level <= ln+1
      8  group by text
      9  /
    TEXT
       NB_WORD
    How     do I count the number of words in my   cell?
            11
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
    SQL> Nicolas.
    Well, we can discuss about what limit a word : here space, but there is point, double-point, and so on... And about what is a word : do the punctuation is a word ?
    For example :
    "It's a word !"=>how many words are in this sentence ?
    http://en.wikipedia.org/wiki/Word
    Message was edited by:
    N. Gasparotto

  • How can I avoid the null values in cross tab?

    How can I avoid the null values in cross tab?

    Hello Anindita,
    Let me explain you the problem in detail.
    I have selected User and Program as rows in the cross tab. In Summarized Field I am counting the Programs.
    In DB I can have both User and Program null.
    Letu2019s take these scenarios...
    1) For a User, Program can be null
    2) For a Program, User can be null
    3) And both can be null.
    A null Program does not give problem since Cross tab does not count the null values and in my case too, it remove the Program which are null from the Cross tab because of the counting its doing on Program. Hence scenario 1 and 3 is not a Problem.
    Problem comes in scenario 2 (For a Program, User can be null).
    In this case since Program is not null it will get counted and will be grouped under null user but I donu2019t want to show the null user Grouping in my cross tab.
    "Suppress empty rows" and "suppress empty colums" does not help.
    Thanks & Regards,
    Amrita

  • How can i select the duplicate values

    Hi experts ,
    how can i find the duplicate values from the table. i want to display the all duplicate the rows.
    1. Table Structure :-
    CREATE TABLE CIF_MIGRATE
      LINE_NO        NUMBER(10),
      ACCT_NO        VARCHAR2(20 BYTE),
      BRANCH_ID      VARCHAR2(1 BYTE),
      CUSTOMER_NAME  VARCHAR2(100 BYTE),
      FATHER_NAME    VARCHAR2(100 BYTE),
      GF_NAME        VARCHAR2(100 BYTE),
      TOTAL          VARCHAR2(100 BYTE),
      STATUS         VARCHAR2(100 BYTE),
      CUSTOMER_TYPE  VARCHAR2(10 BYTE),
      GENDER         VARCHAR2(10 BYTE)
    ) 2. Sample Data:-
    SET DEFINE OFF;
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, CUSTOMER_TYPE)
    Values
       (72, '1', 'Addis Belay Construction Material Rental', 'C');
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, CUSTOMER_TYPE)
    Values
       (73, '1', 'Addis Belay Construction Material Rental', 'C');
    SET DEFINE OFF;
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, CUSTOMER_TYPE, GENDER)
    Values
       (2869, '1', 'Abraham', 'Fiseha',
        'I', 'Male');
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, CUSTOMER_TYPE, GENDER)
    Values
       (2870, '9', 'Abraham', 'Fiseha',
        'I', 'Male');
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, GF_NAME, CUSTOMER_TYPE, GENDER)
    Values
       (2872, '9', 'Abraham', 'Baraki',
        'Medehniye', 'I', 'Female');
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, GF_NAME, CUSTOMER_TYPE, GENDER)
    Values
       (2873, '1', 'Abraham', 'Geber kirstos',
        'gebre medihin', 'I', 'Female');
    Insert into CIF_MIGRATE
       (LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, GF_NAME, CUSTOMER_TYPE)
    Values
       (2874, '1', 'Abraham', 'Gebre egziabher',
        'Negussie', 'I');
    COMMIT;4. My requirement is i need display all the duplication customer
    CUSTOMER_NAME                                 FATHER_NAME,GF_NAME
    Addis Belay Construction Material Rental   
    Addis Belay Construction Material Rental
    Abraham                                              Fiseha
    Abraham                                              Fiseha5. I tried below query but i cant reach what i want exactly
    SELECT CUSTOMER_NAME,FATHER_NAME,GF_NAME
                               FROM CIF_MIGRATE
                          GROUP BY CUSTOMER_NAME,FATHER_NAME,GF_NAME
                             HAVING COUNT (*) > 1kindly suggest me the solution
    Thanks
    Arun

    Hi,
    You're on the right track using COUNT (*), but, for this job, you want the analytic COUNT, not the aggregate COUNT.
    "GROUP BY x, y, z" means that the result set will only contain 1 row for each distinct combination of x, y and z. Most aggregate functions (including COUNT) have analytic counterparts that get the same results without reducing the number of rows.
    Here's one way you can use the analytic COUNT function:
    WITH     got_cnt          AS
         SELECT    customer_name
         ,       father_name
         ,       gf_name
         ,       COUNT (*) OVER ( PARTITION BY  customer_name
                               ,                 father_name
                         ,           gf_name
                         )     AS cnt
         FROM       cif_migrate
    SELECT    customer_name
    ,       father_name
    ,       gf_name
    FROM       got_cnt
    WHERE       cnt     > 1
    ;PARTITION BY in analytic functions corresponds to GROUP BY in aggregate functions.

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • How can I get the edited value from the editor in JTable

    I have a JTextField added as an editor to a cell in JTable.
    I value gets changed when I press enter.
    but in actionPerformed of the JTextField when I say
    String txtEditorValue = txtEditor.getText();
    I am getting the old value. How can I get the edited value? Thanks.

    Hi,
    I guess, your understanding of how JTable works together with its models is not good enough - for example the method getTableCellEditorComponent(...) of the TableCellEditor interface is used to get the component, that should be used as editing component - its second parameter is a value that should be used to setup the editing component - it is normally not the editing component itself.
    JTable uses an underlying TableModel to store the cell values - if you have edited a cell, JTable gets the value of the editing component by itself and stores it in the TableModel using its setValueAt(...) method. To retrieve this data you only need to query the TableModel using row and column of this cell as parameters
    say jt is your JTable, and row and column are the row and column of the cell - so to get the value, simply use
    Object obj = jt.getModel().getValueAt(row,column);
    if you know, that there is a String in this cell use
    String str = (String) jt.getModel().getValueAt(row,column);
    The editor component is used for the view of the JTable - you only want the data, which is stored in the model - you don't have to deal with the GUI components in this case.
    greetings Marsian

  • How can i pass the Input value to the sql file in the korn shell ??

    Hi,
    How can i pass the Input value to the sql file in the korn shell ??
    I have to pass the 4 different values to the sql file and each time i pass the value it has to generate the txt file for that value like wise it has to generate the 4 files at each run.
    can any one help me out.
    Raja

    Can you please more elaberate., perhaps you should more elaberate.
    sqlplus is a program. you start it from the korn shell. when it's finished, processing control returns to the korn shell. the korn shell and sqlplus do not communicate back and forth.
    so "spool the output from .sql file to some txt file from k shell, while passing the input parameters to the sql file from korn shell" makes no sense.

  • How do I count the number of records returned in the CMIS query

    How do I count the number of records returned in the query CMIS?
    SELECT COUNT(*) FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition = \'RD_PROJETOS_EXCLUSIVOS\''}
    Euler Homero

    Hi Euler,
    interestingly enough, the reference guide for CMIS ( http://wiki.alfresco.com/wiki/CMIS_Query_Language ) that I found does not mention the COUNT function at all. On the other hand it states that: "The SELECT clause identifies which virtual columns to return in the result set. It can be either a comma-separated list of one or more queryNames of properties that are defined by queryable object types or * for all virtual columns."
    There are, however, some other posts like e.g. http://alfrescoshare.wordpress.com/2010/01/20/count-the-total-number-of-documents-in-alfresco-using-sql/ which state that they could make it working.
    Having asked in the WebCenter Portal forum, I assume that your content repository is WebCenter Content. The CMIS doc for the Content is available here: http://docs.oracle.com/cd/E23943_01/doc.1111/e15813.pdf (no COUNT there either). It does, however, mention explicitly that "CMIS queries return a Result Set where each Entry object will contain only the properties that were specified in the query.". This means your could rather investigate the Result Set. Note that there are also other means than CMIS how to get the requested result set (e.g. calling a search service directly via so-called RIDC).
    In the given context I am also interested what your use case is. OOTB CMIS in WebCenter Portal is used, for instance, in Content Presenter, where it is content rather than "parameters" what's displayed.

  • How can I get the default value of a particular preference programatically. I know I can see the default value for some of the preferences in about:config but, I need a programatic way to get the default value.

    <blockquote>Locked by Moderator as a duplicate/re-post.
    Please continue the discussion in this thread: [tiki-view_forum_thread.php?comments_parentId=702631&forumId=1]
    Thanks - c</blockquote>
    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    How can I get the default value of a particular preference in FireFox?.
    I know I can see the default value for some of the preferences in about:config but, I need a programatic way to get the default value.
    I see some that there are values for preferences in firefox.cs but I am not certain that these are being used as the default values for preferences. prefs.js in user's profile only has the updated values and not the default values.
    Any help towards acheiving this programtically is greatly appreciated.
    If the default values are stored in a file, kindly let me know the format in which it is stored for me to parse it programatically.
    == User Agent
    ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    Dear Friend,
    Here when you have the callableSattement as ?=proc(?), the first ? is an output parameter. So you should register it as out parameter using registeroutparameter.
    Then you can get the value from the outparameter using callablestatement.getXXX().
    Try that way.
    For free tral versions of JDBC Drivers go to www.Atinav.com

  • How can I get the text value of an XML element  in MXML ?

    Hi,
    I have the following XML loaded into a variable of type XML :
    <properties>
         <comment>RIMpro Data Collector Configuration</comment>
         <entry key="server.pear.username"/>
         <entry key="server.apple.retry.times">5</entry>
         <entry key="rdc.proxy.host">http://192.168.1.2:8080</entry>
    /properties>
    I can easily get the key attribute displayed in a DataGridColumn by setting the dataProvider to my variable and the dataField to "@key".  But I do not know how to get the text value in a second column...  Is there a way or do I need to change my XML to something like this :
    <properties>
         <comment>RIMpro Data Collector Configuration</comment>
         <entry key="server.pear.username"/>
         <entry key="server.apple.retry.times" value="5"></entry>
         <entry key="rdc.proxy.host" value="http://192.168.1.2:8080"></entry>
    /properties>
    Many thanks in advance.
    Marc

    yes, you'd better modify your XML structure to fit the DataGrid internals.
    Since dataField pattern require each grid row item to have a named property to be displayed, otherwise you'll be forced to overcome this pattern using custom labelFunction for the particular column which will implement your custom actions on how to extract appropriate data for that column out of grid row item. It will be much more complicated than just rearranging your xml structure.

Maybe you are looking for

  • How do I REMOVE an ADD-ON from my TOOLBAR, when said ADD-ON does NOT show up in my ADD ONS Manager?

    I have been instructed to: "When you open Firefox up in the left hand corner there is a drop down box that says "Firefox". Click on this and go to add-ons a new page will open with tabs on the side. Click on ADD-ONS, use ADD-ON Manager...." That does

  • How to use This webservice in PHP ?

    Hello. I'm trying to use this webservice in PHP but there isn't a documentation or something that can help me. I have this function, and she returns to me a sessionID : function wslogin() {      global $crmdomain;      $url = $crmdomain . "/Services/

  • 2 spry horizontal menu bars on same site.

    Is it possible to have 2 horizontal menu bars on the same site with different number if items? When I change one to fit the amount of space and words it effects the first one. I named one menu bar 1 and menu bar 2. Thanks for any help you can give. P

  • How do I take a screenshot? (PC or Mac)

    QuestionHow do I take a screenshot? (PC or Mac) Answer Question How do I take a screenshot with a PC? (Scroll down for Mac instructions) Answer If you are experiencing an issue at home that we can't recreate here at Tagged, we often ask that you send

  • Unable to update Java to the latest version

    When I try to update Java, when I get to 'Close Programs to Continue', one of the programs I am told I need to close is 'Start'. Doing this means I have to restart Windows 7. The problem is that the Java installation doesn't resume after I've done th