ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Count Unique in Pivot Table (https://www.excelbanter.com/excel-discussion-misc-queries/163279-count-unique-pivot-table.html)

Abhay

Count Unique in Pivot Table
 
I have a Excel sheet with data like
OBS name hours
obs1 abb 10
obs1 abb 12
obs1 abc 15

End result I would like to see is
obs 1 , count of unique name, sum of hours
obs1, 2, 37

In existing Pivot table if I use Count on name field it returns 3 as there
are three rows. I wish to have count on unique Name per obs. Thanks for help.


Roger Govier[_3_]

Count Unique in Pivot Table
 
Hi

You could add a 4th column to your data, titled Unique
In cell D2 enter
=IF(COUNTIF($B$2:$B2,B2)1,"",COUNTIF($B$2:$B2,B2) )
and copy down for the extent of your data.

In the PT, drag Unique to the Data area as SUM of Unique and you will get a
result of 2
If you use Count, then it will still return a result of 3

--
Regards
Roger Govier



"Abhay" wrote in message
...
I have a Excel sheet with data like
OBS name hours
obs1 abb 10
obs1 abb 12
obs1 abc 15

End result I would like to see is
obs 1 , count of unique name, sum of hours
obs1, 2, 37

In existing Pivot table if I use Count on name field it returns 3 as there
are three rows. I wish to have count on unique Name per obs. Thanks for
help.




Abhay

Count Unique in Pivot Table
 
Thanks Roger. This helps for sure, I was wondering if there is smarter way in
PT.
I could not get why second COUNTIF is used though.


"Roger Govier" wrote:

Hi

You could add a 4th column to your data, titled Unique
In cell D2 enter
=IF(COUNTIF($B$2:$B2,B2)1,"",COUNTIF($B$2:$B2,B2) )
and copy down for the extent of your data.

In the PT, drag Unique to the Data area as SUM of Unique and you will get a
result of 2
If you use Count, then it will still return a result of 3

--
Regards
Roger Govier



"Abhay" wrote in message
...
I have a Excel sheet with data like
OBS name hours
obs1 abb 10
obs1 abb 12
obs1 abc 15

End result I would like to see is
obs 1 , count of unique name, sum of hours
obs1, 2, 37

In existing Pivot table if I use Count on name field it returns 3 as there
are three rows. I wish to have count on unique Name per obs. Thanks for
help.






All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com