Yeah, same thing, basically. That's what I'm doing and it's seriously taking forever to calculate.
.Range("k2").Formula = "=sum(1/COUNTIF($C$2:$C$" & lastRow & ",C2),0)"
DelCount.FillDown
Main Topics
Browse All TopicsHi, all.
I need to get unique counts for a pivot table and am currently using a FillDown of something like:
=SUM(1/COUNTIF(C:C,C2),0)
(but am actually just using the UsedRange instead of "C:C") and then doing a Sum field in the pivot table.
This works and everything, but can take many, many minutes to calculate. I think it took about 25 minutes for 40k records on this laptop (which is somewhat old, but still....)
Are there some other/better methods for doing this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Not sure if this is what you mean but if you want to get a unique list from a column of data without draging down 40K rows of formulas you can simply do it using the Advance Filter which would be much quicker...to do this:
1. Go to Data then Advance Filter
2. Check "Copy to Another Location"
3. Highlight the column of data with a header cell included (header cell = title of data below...ie "SALES") 4. For the "Copy to" highlight a range where you want the results to go...be sure this area is large enough to hold the results...keep same length as original data to be sure
5. Click the "Unique Records Only" radial dial
6. Click OK.
This will paste a copy of ONLY the unique records from the original column of data into the new location. This can also be done programmatically in VBA.
Adam,
Good to know, but I don't think that's going to help a lot.
Basically, my data dump sheet has tens of thousands of order lines. The Pivot counter will return the number of lines per order, but I also need to return the number of orders. That's where I need to do a distinct count and have the ability to use it in my Pivot.
"Basically, my data dump sheet has tens of thousands of order lines. The Pivot counter will return the number of lines per order, but I also need to return the number of orders. That's where I need to do a distinct count and have the ability to use it in my Pivot."
Why not do a COUNT on the "Order Number" field. It will give you a count of the line items per order and a grand total of all orders. Am I missing something? Is there not an order number associated with the lines?
See attached file for example.
If I understand you correctly you're happy with the count per order (ie 1234 = 20) but what you're not happy with is the Grand Total saying 167 instead of 4...is this what you want (4)? If so what I would do, again not being familiar with Pivots, is just put a summary row above your pivot that does a count of column A...I tried this on your spreadsheet and it gave me a result of 4. You could put some fancy formatting and add the grand total count as well and it would look professional...see attached:
FYI there's a formula in D1 but the font is white to keep it from being visible...you could protect this if need be.
Adam & Starfailure,
The two formulas that you have in cell B2 to get the Grand Total can be substituted with a GETPIVOTDATA statement. The easiest way to do this is to put an equal sign ( = ) in B2 and then click on the 167 on the Grand Total line. It will produce a statement like:
=GETPIVOTDATA("Order#
If you need a distinct count in a pivot, you need a formula in the data. I'm not sure what purpose the SUM part is supposed to serve, so I would remove it. You can also assign the formula to all rows in one go without the filldown, but I'm not sure that will speed things up. Do you actually use the pivot for something else too?
I guess Rory and I had similar thoughts.... I was working on this just came back to the post with an alternate solution and saw Rory's comment. You can use the following formula to generate a unique number that you can filter on in the PT. I am sure there are other solutions but look at the attached file and see if this helps...
=SUMPRODUCT( --(A$2:A2=A2))
Business Accounts
Answer for Membership
by: roryaPosted on 2009-03-26 at 05:30:07ID: 23989542
Do you mean the formula is =1/COUNTIF(C:C,C2) and you are doing the Sum in the pivot table? The only way of getting a distinct count is to add a column to the raw data, but I'm surprised it's that slow.