How do I do a Count distinct of a column ?

excelusername

New Member
Joined
Nov 23, 2017
Messages
3
If I have a table like this, that's like an audit table of dates users run reports.

Report User Date

Fin Fred 1/2/2018
Fin Fred 2/2/2018
Fin John 1/2/2018
HR Fred 3/2/2018
HR Fred 4/2/2018
HR Steve 4/2/2018
HR Jane 4/2/2018

And I want to calculate the number of Users that have used each report, to produce

Report #Users

Fin 2
HR 3

Or number of users that have used each report each day

Report Date #Users
Fin 1/2/2018 2
Fin 2/2/2018 1
HR 3/2/2018 1
HR 4/2/2018 3

All help much appreciated! Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try setting up a pivot table to do this !
Highlight the data
Insert Tab
Pivot Table
Report column will be the filter
Row label will be the users
And dates will be the data
 
Upvote 0
Maybe distinct counts are available in pivot tables in latest Excel versions, I don't know.

If not, suggest you account for that requirement when creating the pivot tables. This is available in all Excel versions with pivot tables,
- first PT. SELECT DISTINCT Report, User FROM yourtable
- 2nd PT. SELECT DISTINCT Report, [Date], User FROM yourtable

Date name for field can be problematic. Hopefully enclosing Date in brackets will suffice. If not next step up is to include table reference. Such as
SELECT DISTINCT T.Report, T.[Date], T.User FROM table T

Instead of pivot tables, you can use query tables, btw. Either way these approaches will work well with huge datasets (that may be too slow with formulas).

cheers
 
Upvote 0

Forum statistics

Threads
1,215,839
Messages
6,127,199
Members
449,368
Latest member
JayHo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top