dbTalk Databases Forums  

MDX filter problem (HARD)!

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


Discuss MDX filter problem (HARD)! in the microsoft.public.sqlserver.olap forum.



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

Default MDX filter problem (HARD)! - 05-17-2004 , 01:25 PM






I'm trying to do a filter that uses {[Period].[Months].Members} as the
set that will be filtered and uses as the condition of the filter a
reference to the current member of the Period dimension, outside the
set of the filter. To resolve it I've tried to use an alias set, as in
the following expression:

Filter ({[Period].[Months].Members} AS FilterSet,
(FilterSet.CurrentMember,[Schedule].[Amount]) > Rank
([Period].CurrentMember, {[Period].[Months].Members}) – Rank
(FilterSet.CurrentMember, {[Period].[Months].Members})

I want to filter the member of the Period dimension where the tuple
([Period], [Schedule].[Amount]) is more than the distance between the
Period member of the filter set and the current member of Period
dimension (outside the filter set). But, despite that the expression's
syntax is correct, the expression:

Rank ([Period].CurrentMember, {[Period].[Months].Members}) – Rank
(FilterSet.CurrentMember, {[Period].[Months].Members})

Always returns zero, so the AS don't understand that the
[Period].CurrentMember is referencing the external member of the
Period dimension and not the member of the filter set.

Does anybody can help me??

By the way, the formula that I'm trying is simple but a quite complex
to explain, take a look at the following example:

Assume that the values between the vertical bars mean:

Quote:
[Schedule].[Amount of Payments], [Schedule].[Monthly Cost]|
Jan Feb Mar Apr
Quote:
3,200| |4,100| |2,500| |3,300|
So, the Monthly Cost 200 of Jan must be added to the result of the
formula in Jan, Feb and Mar, because the Amount of Payments is 3. In
the same way, the Monthly Cost 100 of Feb must be added to the result
formula in Feb, Mar, Apr and May. Therefore, the result of the formula
for the example above should be:

Jan Feb Mar Apr May Jun
200 300 800 900 400 300

And the entire expression that I've tried to calculate this is:

Sum( Filter ({[Period].[Months].Members} AS FilterSet,
(FilterSet.CurrentMember,[Schedule].[Amount of Payments]) >
Rank([Perid].CurrentMember, {[Period].[Months].Members}) - Rank
(FilterSet.CurrentMember, {[Period].[Months].Members})
),
[Schedule].[Monthly Cost])

But it doesn't work because inside a filter condition, for the reason
that the filter set is the [Period].[Months] members, all references
to the CurrentMember of the Period dimension will be understood as the
CurrentMember member of the filter set. One solution could by use also
like a variable, setting its values before enter in the filter
expression, but I don't if its possible.


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

Default Re: MDX filter problem (HARD)! - 05-17-2004 , 08:21 PM






Based on the sample data, there are a couple of issues:

- The Alias Set is not saving the [Period] context

- [Monthly Cost] of future months is added into prior


This MDX expression should address those 2 issues:

Quote:
Sum({Period.CurrentMember} as PeriodSet,
Sum(Filter([Period].[Months].Members,
(Period.CurrentMember,[Schedule].[Amount of Payments]) >
Rank([PeriodSet].Item(0),[Period].[Months].Members)
- Rank(Period.CurrentMember,[Period].[Months].Members)
And Rank([PeriodSet].Item(0),[Period].[Months].Members)
Quote:
= Rank(Period.CurrentMember,[Period].[Months].Members)),
[Schedule].[Monthly Cost]))


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #3  
Old   
Vinicius Bellino
 
Posts: n/a

Default Re: MDX filter problem (HARD)! - 05-18-2004 , 12:15 PM



Yes, actually my problem was with the first issue that you wrote and
your solution resolved it, the second one I knew about it but I was
trying to resolve the first before.

Very interesting this way to "emulate" a variable before the filter,
creating a new Sum with one member, outside the filter, just to AS
understand exactly what PeriodSet refers to.

About the second issue, I prefered to limit the set of the filter to
the months before the current month, take a look in the formula that I
used:

Sum({[Period].CurrentMember} as PeriodSet,
Sum(Filter({([Period].[Months].Members.Item(0):[Período].CurrentMember)},
([Schedule].[Amount of Payments])>
(Rank(PeriodSet.Item(0),{[Period].[Months].Members}) -
Rank([Period].CurrentMember,
{[Period].[Months].Members}))
),
[Schedule].[Monthly Cost]))

Thank you,

Vinicius Bellino



Deepak Puri <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
Based on the sample data, there are a couple of issues:

- The Alias Set is not saving the [Period] context

- [Monthly Cost] of future months is added into prior


This MDX expression should address those 2 issues:


Sum({Period.CurrentMember} as PeriodSet,
Sum(Filter([Period].[Months].Members,
(Period.CurrentMember,[Schedule].[Amount of Payments])
Rank([PeriodSet].Item(0),[Period].[Months].Members)
- Rank(Period.CurrentMember,[Period].[Months].Members)
And Rank([PeriodSet].Item(0),[Period].[Months].Members)
= Rank(Period.CurrentMember,[Period].[Months].Members)),
[Schedule].[Monthly Cost]))



- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: MDX filter problem (HARD)! - 05-18-2004 , 02:58 PM



You're right, limiting the set to prior months is simpler than adding
that condition in the filter. If the [Period] dimension has an [All]
level, then this is equivalent to:

PeriodsToDate([Period].[All])


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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.