+ Reply to Thread
Results 1 to 4 of 4

Count unique values - Pivot Table

  1. #1
    Thomas Mueller
    Guest

    Count unique values - Pivot Table

    Hi,

    I've some problems to count unique items (Invoice #) in a pivot table. There
    is the default solution "Add-a-new-calculated-column" as mentioned on
    http://contextures.com/xlPivot07.html#Unique, but in my case, it doesn't
    works.

    My problem is, that these values aren't in a Excel worksheet; it's a
    external data source - a SQL-Select via DAO/ADO. Because of that, I don't
    have the possibility to add a new column. Another reason is, that the pivot
    table should always be dynamic: Group over this field, group over another
    field - and always show the number of unique invoices, not the sum of data
    rows (please take a look at the Excel sheet:
    http://e-tom.ch/Count_Unique_Invoice_No.xls).

    Thx, Thomas

    (or is there an easy way to write an User Definied Function and access to
    the data rows in each pivot table group?)




  2. #2
    Gary76
    Guest

    RE: Count unique values - Pivot Table

    How about something like:

    =SUMPRODUCT(1/COUNTIF(Data!$A$2:$A$24,Data!$A$2:$A$24)*(Data!$B$2:$B$24=Pivot!B6))

    in E6 (copied down), and something like:

    =COUNTIF(Data!$C$2:$C$24,Pivot!G7)

    in J7 (copied down)

    HTH

    "Thomas Mueller" wrote:

    > Hi,
    >
    > I've some problems to count unique items (Invoice #) in a pivot table. There
    > is the default solution "Add-a-new-calculated-column" as mentioned on
    > http://contextures.com/xlPivot07.html#Unique, but in my case, it doesn't
    > works.
    >
    > My problem is, that these values aren't in a Excel worksheet; it's a
    > external data source - a SQL-Select via DAO/ADO. Because of that, I don't
    > have the possibility to add a new column. Another reason is, that the pivot
    > table should always be dynamic: Group over this field, group over another
    > field - and always show the number of unique invoices, not the sum of data
    > rows (please take a look at the Excel sheet:
    > http://e-tom.ch/Count_Unique_Invoice_No.xls).
    >
    > Thx, Thomas
    >
    > (or is there an easy way to write an User Definied Function and access to
    > the data rows in each pivot table group?)
    >
    >
    >
    >


  3. #3
    Thomas Mueller
    Guest

    Re: Count unique values - Pivot Table

    Jep, first formula works correctly, thx! But I'd like to have something like
    a pivot field - gives the clients the possibility to add this field to the
    pivot table with drag'n'drop - without a "hack".

    I'll write a User Defined Function and put it in a calculated field, the
    only way to solve this problem (in my eyes).
    A lot of people have been having this problem for years - but there is no
    Excel built-in function... Looks like nobody of the Excel Dev Team cares
    about...

    Thx, Thomas


    "Gary76" <[email protected]> schrieb im Newsbeitrag
    news:[email protected]...
    > How about something like:
    >
    > =SUMPRODUCT(1/COUNTIF(Data!$A$2:$A$24,Data!$A$2:$A$24)*(Data!$B$2:$B$24=Pivot!B6))
    >
    > in E6 (copied down), and something like:
    >
    > =COUNTIF(Data!$C$2:$C$24,Pivot!G7)
    >
    > in J7 (copied down)
    >
    > HTH
    >
    > "Thomas Mueller" wrote:
    >
    >> Hi,
    >>
    >> I've some problems to count unique items (Invoice #) in a pivot table.
    >> There
    >> is the default solution "Add-a-new-calculated-column" as mentioned on
    >> http://contextures.com/xlPivot07.html#Unique, but in my case, it doesn't
    >> works.
    >>
    >> My problem is, that these values aren't in a Excel worksheet; it's a
    >> external data source - a SQL-Select via DAO/ADO. Because of that, I don't
    >> have the possibility to add a new column. Another reason is, that the
    >> pivot
    >> table should always be dynamic: Group over this field, group over another
    >> field - and always show the number of unique invoices, not the sum of
    >> data
    >> rows (please take a look at the Excel sheet:
    >> http://e-tom.ch/Count_Unique_Invoice_No.xls).
    >>
    >> Thx, Thomas
    >>
    >> (or is there an easy way to write an User Definied Function and access to
    >> the data rows in each pivot table group?)
    >>
    >>
    >>
    >>




  4. #4
    Debra Dalgleish
    Guest

    Re: Count unique values - Pivot Table

    You won't be able to use a User Defined Function in a pivot table's
    calculated field.

    Thomas Mueller wrote:
    > Jep, first formula works correctly, thx! But I'd like to have something like
    > a pivot field - gives the clients the possibility to add this field to the
    > pivot table with drag'n'drop - without a "hack".
    >
    > I'll write a User Defined Function and put it in a calculated field, the
    > only way to solve this problem (in my eyes).
    > A lot of people have been having this problem for years - but there is no
    > Excel built-in function... Looks like nobody of the Excel Dev Team cares
    > about...
    >
    > Thx, Thomas
    >
    >
    > "Gary76" <[email protected]> schrieb im Newsbeitrag
    > news:[email protected]...
    >
    >>How about something like:
    >>
    >>=SUMPRODUCT(1/COUNTIF(Data!$A$2:$A$24,Data!$A$2:$A$24)*(Data!$B$2:$B$24=Pivot!B6))
    >>
    >>in E6 (copied down), and something like:
    >>
    >>=COUNTIF(Data!$C$2:$C$24,Pivot!G7)
    >>
    >>in J7 (copied down)
    >>
    >>HTH
    >>
    >>"Thomas Mueller" wrote:
    >>
    >>
    >>>Hi,
    >>>
    >>>I've some problems to count unique items (Invoice #) in a pivot table.
    >>>There
    >>>is the default solution "Add-a-new-calculated-column" as mentioned on
    >>>http://contextures.com/xlPivot07.html#Unique, but in my case, it doesn't
    >>>works.
    >>>
    >>>My problem is, that these values aren't in a Excel worksheet; it's a
    >>>external data source - a SQL-Select via DAO/ADO. Because of that, I don't
    >>>have the possibility to add a new column. Another reason is, that the
    >>>pivot
    >>>table should always be dynamic: Group over this field, group over another
    >>>field - and always show the number of unique invoices, not the sum of
    >>>data
    >>>rows (please take a look at the Excel sheet:
    >>>http://e-tom.ch/Count_Unique_Invoice_No.xls).
    >>>
    >>>Thx, Thomas
    >>>
    >>>(or is there an easy way to write an User Definied Function and access to
    >>>the data rows in each pivot table group?)
    >>>
    >>>
    >>>
    >>>

    >>

    >
    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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