dbTalk Databases Forums  

MDX query between dates keeping aggregates to selected period only

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


Discuss MDX query between dates keeping aggregates to selected period only in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
siuch@konto.pl
 
Posts: n/a

Default MDX query between dates keeping aggregates to selected period only - 11-21-2006 , 07:36 AM






I'm new to MDX , and have big problem
I need to give the user ability to interactive filter [Time] dimension
to 'between' dates, but I also need to keep hierarchy of time and
aggregation in the selected period.
I'm using Mondrian and OpenI (JPivot).

I have cube with 2 dimensions
-[Time]
* all
** year
*** quarter,
**** month
***** day
and
-[Measure].[document_value]

I have document values from last 10 years for every day.

I tried to use Filter function or enumerate [Time] members , but when I
for example filtered-out all time members and left only:
Quarter1 and Quarter4 from 1989
still had 'year' level aggregation equal sum of four quarters , and
'all years' equal sum of all (for example 10) years ((((

How to cope with it?? Is there a nice and efficient way to solve my
problem???

P.S. User can select for example dates between 2006.05.12 - 18.09.2006
so (as I understand )every middle aggregation needs to be 're-defined'
How to do it


Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: MDX query between dates keeping aggregates to selected period only - 11-21-2006 , 11:08 AM






Does this thread from the newsgroup apply to your scenario?

http://groups.google.com/group/micro...olap/msg/66361
802c533e52a?hl=en&
Quote:
microsoft.public.sqlserver.olap > How to simplify such set
{MemberI:MemberN}?

From: Vladimir Chtepa
Date: Sat, Jul 1 2006 5:18 pm

Hi Deepak,thank your for the link to the Chris bolg.I have find another
a
little optimised formula without descendants(...,,LEAVES).with
-- initial set.
set set1 as
{[Date].[Calendar].[Month].&[2001]&[8]:[Date].[Calendar].[Month].&[2003]
&[5*]}
set set2 as generate(set1,
{ascendants([Date].[Calendar].currentmember)})
set set3 as generate({set1.Item(0).Item(0).PrevMember, tail(set1,
1).Item(0).Item(0).NextMember},
{ascendants([Date].[Calendar].currentmember)})
set set4 as set2 - set3
set set5 as filter(set4, ({[Date].[Calendar].currentmember.parent} -
set4).count > 0)

select {} on 0,
set5 on 1
from [Adventure Works]It works also for for abrbitrary level.


"Deepak Puri" <deepak_p... (AT) progressive (DOT) com> wrote


Quote:
Hi Vladimir,

Looks like this is similar to the problem addressed by these 2 entries
in Chris Webb's blog:

Quote:
http://spaces.msn.com/members/cwebbbi/Blog/cns!1pi7ETChsJ1un_2s41jm9Iyg!
107.entry

Quote:
http://spaces.msn.com/members/cwebbbi/Blog/cns!1pi7ETChsJ1un_2s41jm9Iyg!
111.entry
...


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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

Default Re: MDX query between dates keeping aggregates to selected period only - 11-22-2006 , 06:21 AM



Hi Deepak
Thanks for reply

I don't think that thread you proposed can help to solve my problem.
Maybe I just don't know how to use it properly (which is quite
probable)(if so - tell me)

or
I poorly explained what the problem is.

To better explain what's the point, I draw a kind of pivot table to
show what I finally want to get

http://213.25.33.253/~tomeks/mdx/MDX_problem.htm

Any suggestions are very appreciated

Tomek


Reply With Quote
  #4  
Old   
Deepak Puri
 
Posts: n/a

Default Re: MDX query between dates keeping aggregates to selected period only - 11-22-2006 , 09:24 AM



Hi Tomek,

Thanks for the pivot table illustration - it seems to show a typical
VisualTotals() usage scenario (if that MDX function is available in your
environment):

http://msdn2.microsoft.com/en-us/library/ms145527.aspx
Quote:
SQL Server 2005 Books Online

VisualTotals (MDX)
Updated: 17 July 2006

Returns a set generated by dynamically totaling child members in a
specified set, optionally using a pattern for the name of the parent
member in the result set.
...
Examples

The following example returns the visual total for the third quarter of
the 2001 calendar year based on the single descendant specified - the
month of July.

SELECT VisualTotals
({[Date].[Calendar].[Calendar Quarter].&[2001]&[3]
,[Date].[Calendar].[Month].&[2001]&[7]}) ON 0
FROM [Adventure Works]
...
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #5  
Old   
siooh
 
Posts: n/a

Default Re: MDX query between dates keeping aggregates to selected period only - 11-23-2006 , 03:01 AM



Hi Deepak

That's what I've been looking for!!!
There is VisualTotals() function in Mondrian.

Thank you very much.

Tomek


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.