Distinct Counting

testsubjec

New Member
Joined
Jul 14, 2011
Messages
33
Hi,

I have a SQL Query which pulls in information from our Warehouse System and the user is then able to set filters etc.

What I'd like to be able to do is do a Distinct Count on the filtered data but I cannot seem to be able to achieve this.

Please could you help.

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Can you post your code, maybe a small example of your data, and your expected results?
 
Upvote 0
The OP could try to adapt from the following example formula for distinct count, applied to an autofiltered range:

Control+shift+enter, not just enter...
Rich (BB code):
=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(O5,ROW(O5:O22)-ROW(O5),,1)),
  IF(O5:O22<>"",MATCH("~"&O5:O22,O5:O22&"",0))),
   ROW(O5:O22)-ROW(O5)+1),1))

The range which houses the relevant items is O5:O22, while O4 is supposed to house a header.
 
Upvote 0
Would it not be easier to have the SQL return the distinct count with the data? It is a standard function within SQL.
 
Upvote 0

Forum statistics

Threads
1,225,613
Messages
6,186,004
Members
453,334
Latest member
Prakash Jha

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