Search code examples
mdxolap

MDX 'is not equal to' in where clause


I want to divide [Net sales] from all years by the [Year] and [Week] until now and I got problem.

I wrote two queries, but both doesn't work.

First one is basic, I just show [Net sales] divided by Weeks and Years, just how I wanted, but firstly: I'm showing weeks and years even if [Net sales] are Null, and secondly, there is 'All' member of [Year] and [Week] which isn't desired to appear.

How do I filter out the [All] and null values?

Actual query:

select  
{[Measures].[Net sales]} on columns,
{([Time].[Year].MEMBERS,
    [Time].[Week].MEMBERS )} on rows
from [Sales]
where ( 
{[Department].[Department name].&[WRO], [Department].[Department name].&[KAT]});

Second query, that doesn't work at all. This was a try to filter out [All] member of [Year].

select  
{ [Measures].[Net sales] } on columns,
{ [Time].[Week].MEMBERS } on rows
from [Sales]
where ( except([Time].[Year].MEMBERS, [Time].[Year].&[All]),
    {[Department].[Department name].&[WRO], [Department].[Department name].&[KAT]});

Summary: I want to present only Net Sales divided by weeks periods. Weeks should be groupped in years.


Solution

  • To filter out the [All] member, use CHILDREN instead of MEMBERS.

    To not get Weeks and Years that have no Net Sales, use NON EMPTY:

       NON EMPTY {([Time].[Year].CHILDREN,
            [Time].[Week].CHILDREN )} on rows