dbTalk Databases Forums  

MDX - Counting populated cells and summarising

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


Discuss MDX - Counting populated cells and summarising in the microsoft.public.sqlserver.olap forum.



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

Default MDX - Counting populated cells and summarising - 10-08-2003 , 04:01 AM






Hi there
I have an MDX problem that I need some help with,
hopefully someone out there can be that help...

I want a measure to be the number of populated cells in a
cube which can then get summed when aggregated.

I started with the following:

with member [Measures].[measure2] as
'IIF( [Measures].[measures1] > 0, 1, 0)'

which works for stuff at the leaf level but doesn't get
aggregated up over the hierarchy.
e.g. The following query
select measures.measure2 on columns,
time.month.members on rows
from MyCube
returns
Jan 1
Feb 1
Mar 1
Apr 1
May 1
etc...

but this isn't what I want. What I want is (for example)
if there are 14 days in [Jan] that have a value greater
than 0 for measure1, then ([Jan], [measure2]) should
return 14.

How do I do this?

Hopefully I've explained the problem succinctly enough. If
not, please let me know.

Regards and thanks in advance.
Jamie Thomson


Reply With Quote
  #2  
Old   
Lionel Billon [MVP]
 
Posts: n/a

Default Re: MDX - Counting populated cells and summarising - 10-08-2003 , 09:43 AM






Hi Jamie,

You should try something like :
Say for example that Day level is the leaf level of the time dimension :

with member [Measures].[Measures2] as
'Count(Filter(Descendants(Time.currentmember,Time. [Day]),Measures.[Measures1
]>0))'
select measures.measure2 on columns,
time.month.members on rows
from MyCube

HTH,

Lionel BILLON
MVP SQL Server
http://www.olapwebhouse.com




"Jamie Thomson" <jamie.thomson (AT) int21 (DOT) com> wrote

Quote:
Hi there
I have an MDX problem that I need some help with,
hopefully someone out there can be that help...

I want a measure to be the number of populated cells in a
cube which can then get summed when aggregated.

I started with the following:

with member [Measures].[measure2] as
'IIF( [Measures].[measures1] > 0, 1, 0)'

which works for stuff at the leaf level but doesn't get
aggregated up over the hierarchy.
e.g. The following query
select measures.measure2 on columns,
time.month.members on rows
from MyCube
returns
Jan 1
Feb 1
Mar 1
Apr 1
May 1
etc...

but this isn't what I want. What I want is (for example)
if there are 14 days in [Jan] that have a value greater
than 0 for measure1, then ([Jan], [measure2]) should
return 14.

How do I do this?

Hopefully I've explained the problem succinctly enough. If
not, please let me know.

Regards and thanks in advance.
Jamie Thomson




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.