dbTalk Databases Forums  

Distinct count MDX question

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Distinct count MDX question in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Nedra
 
Posts: n/a

Default Distinct count MDX question - 03-09-2006 , 04:32 PM






I am trying to get the distinct number of accounts that have subscribed
to recieve emails about cruises, have had a past trip between 2004 and
2006, and have flown out of either the Seattle or Houston airports.

My MDX is given below. It is returning the number of accounts but not
the number of distinct accounts. Could anyone give me some insite on
how to change this query to return distinct accounts?

Thanks. -- Nedra

SELECT
NON EMPTY
CROSSJOIN (
CROSSJOIN (
{[Sub_CruisesDim].[All Sub_CruisesDim]}
, {filter( {[Departure Date].[All Departure
Date]}, [Departure Date].[All Departure Date] >= 2004 or [Departure
Date].[All Departure Date] <= 2006) }
)
, {
filter ( {[DepartureAirport_Dim].[All
DepartureAirport_Dim]}, Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[IAH]) or Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[SEA]))
}
)
ON COLUMNS

FROM
[Account_Fact]
WHERE
([Measures].[Account Id])


Reply With Quote
  #2  
Old   
Jéjé
 
Posts: n/a

Default Re: Distinct count MDX question - 03-09-2006 , 05:26 PM






the distinct keyword can do it.

select non empty distinct(....)

but you talk about a distinct "number" or ditinct "list"?


"Nedra" <nedraalbrecht (AT) hotmail (DOT) com> wrote

Quote:
I am trying to get the distinct number of accounts that have subscribed
to recieve emails about cruises, have had a past trip between 2004 and
2006, and have flown out of either the Seattle or Houston airports.

My MDX is given below. It is returning the number of accounts but not
the number of distinct accounts. Could anyone give me some insite on
how to change this query to return distinct accounts?

Thanks. -- Nedra

SELECT
NON EMPTY
CROSSJOIN (
CROSSJOIN (
{[Sub_CruisesDim].[All Sub_CruisesDim]}
, {filter( {[Departure Date].[All Departure
Date]}, [Departure Date].[All Departure Date] >= 2004 or [Departure
Date].[All Departure Date] <= 2006) }
)
, {
filter ( {[DepartureAirport_Dim].[All
DepartureAirport_Dim]}, Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[IAH]) or Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[SEA]))
}
)
ON COLUMNS

FROM
[Account_Fact]
WHERE
([Measures].[Account Id])




Reply With Quote
  #3  
Old   
Nedra
 
Posts: n/a

Default Re: Distinct count MDX question - 03-10-2006 , 12:31 AM



I am trying to get the distinct number of account ids. I think I read
somewhere this is called basket analysis (?). I'm very new to this, so
I'm mostly just fumbling around trying to get queries to work.

I tried to change my query to this:

with member measures.a
as 'distinctcount(
{ NONEMPTYCROSSJOIN (
CROSSJOIN (
{[Sub_CruisesDim].[All Sub_CruisesDim]}
, {filter( {[Departure Date].[All Departure
Date]}, [Departure Date].[All Departure Date] >= 2004 or [Departure
Date].[All Departure Date] <= 2006) }
)
, {
filter ( {[DepartureAirport_Dim].[All
DepartureAirport_Dim]}, Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[IAH]) or Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[SEA]))
}
)})'

SELECT
measures.a
ON COLUMNS

FROM
[Account_Fact]
where
[Measures].[Account Id]

I get an error saying that measures.a is unbindable in the current
context. Any ideas where I'm going wrong?

TIA - Nedra


Reply With Quote
  #4  
Old   
Jéjé
 
Posts: n/a

Default Re: Distinct count MDX question - 03-10-2006 , 05:53 PM



first, try :
select measures.a on 0
from CubeName

second, do you use AS2005 or AS2000?

after...
the nonemptycrossjoin function support more then 2 sets at the same time!
nonemptycrossjoin(set1, set2, set3 ....)

the nonemptycrossjoin return a non empty set, so a simple count is enough
instead-of a the distinctcount formula.
(distinctcount will exclude empty cells which are allready exclude using the
nonemptycrossjoin; double work for nothing)

with member measures.a
as 'count(
NONEMPTYCROSSJOIN (
[Sub_CruisesDim].[All Sub_CruisesDim].MEMBERS
, filter( [Departure Date].[All Departure
Date].MEMBERS, [Departure Date].[All Departure Date] >= 2004 or [Departure
Date].[All Departure Date] <= 2006)
,
filter ( [DepartureAirport_Dim].[All
DepartureAirport_Dim].MEMBERS, Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[IAH]) or Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[SEA]))
)
)'

and you are right, its a basket analysis way.
search on the MSDN web site to find samples.


"Nedra" <nedraalbrecht (AT) hotmail (DOT) com> wrote

Quote:
I am trying to get the distinct number of account ids. I think I read
somewhere this is called basket analysis (?). I'm very new to this, so
I'm mostly just fumbling around trying to get queries to work.

I tried to change my query to this:

with member measures.a
as 'distinctcount(
{ NONEMPTYCROSSJOIN (
CROSSJOIN (
{[Sub_CruisesDim].[All Sub_CruisesDim]}
, {filter( {[Departure Date].[All Departure
Date]}, [Departure Date].[All Departure Date] >= 2004 or [Departure
Date].[All Departure Date] <= 2006) }
)
, {
filter ( {[DepartureAirport_Dim].[All
DepartureAirport_Dim]}, Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[IAH]) or Not IsEmpty([DepartureAirport_Dim].[All
DepartureAirport_Dim].[SEA]))
}
)})'

SELECT
measures.a
ON COLUMNS

FROM
[Account_Fact]
where
[Measures].[Account Id]

I get an error saying that measures.a is unbindable in the current
context. Any ideas where I'm going wrong?

TIA - Nedra




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.