SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Distinct count


Distinct count

Author
Message
yvesvanlathem
yvesvanlathem
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 48
Hi all,

Prolly easy question, but for some reason the query below does not return the distinct count but just the count. Should be 16 but it's retruning 17. Any help? Smile

WITH SET [MySet] AS
NONEMPTY(
FILTER(
[Geography].[City].[City].Members,
instr(left([Geography].[City].currentmember.name,1), 'A') > 0
),
[Measures].[Internet Order Count]
)

MEMBER [Measures].[CountMembers] AS
DISTINCTCOUNT([MySet])
//why not distinct?

SELECT {
[Measures].[Internet Order Count],
[Measures].[CountMembers]
}
ON COLUMNS,

[MySet]

ON ROWS
FROM [Adventure Works]

PB_BI
PB_BI
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4189 Visits: 2732
It's returning 17 as there are 17 members in your set.
Augsburg is listed twice but it's still two distinct members that have different properties further up the hierarchy -
[Geography].[Geography].[City].&[Augsburg]&[HH]
[Geography].[Geography].[City].&[Augsburg]&[BY]
One is in the Bayern province and the other is in Hamburg.




I'm on LinkedIn
yvesvanlathem
yvesvanlathem
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 48
Hi,

Thanks for your answer! I found that out yesterday as well after searching a while .. :/

Thanks!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search