Writing calclulated member with where clause

Is it possible to rewrite this MDX query to a simple member including all conditions:
WITH MEMBER test as
SUM([Measures].[Amount],[DIM Bus Post Group].[Code].&[A])
Select {test} on 0
from [OLAP]
WHERE ([DIM Customer].[Cust Num].children - [DIM Customer].[Cust Num].&[0000])

to somehing like this(is not working though)
WITH MEMBER test as
SUM([Measures].[Amount],([DIM Bus Post Group].[Tegund].&[A],[DIM Customer].[Cust Num].children - [DIM Customer].[Cust Num].&[0000]))
Select {test} on 0
from [OLAP]

Open in new window

gosi75Business Intelligence ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Megan BrooksSQL Server ConsultantCommented:
I am not an MDX expert by any means but placing
([DIM Bus Post Group].[Tegund].&[A],[DIM Customer].[Cust Num].children - [DIM Customer].[Cust Num].&[0000])
in a tuple as if it were an attribute hierarchy doesn't look right to me. What do you want to do with that expression (the one I just quoted)?
0
gosi75Business Intelligence ConsultantAuthor Commented:
I wanted to add this as a calculated member in my OLAP
0
Megan BrooksSQL Server ConsultantCommented:
So the expression above is a calculation, then? I see what looks like two calculations:
SUM([Measures].[Amount],[DIM Bus Post Group].[Code].&[A])
and
[DIM Bus Post Group].[Tegund].&[A],[DIM Customer].[Cust Num].children - [DIM Customer].[Cust Num].&[0000]
The second one, however, appears to be subtracting a member from a set. Did you want the difference between each member of the set and the member with key &[0000]? What did you want to do with those differences?
You want these returned as a single calculated member? Do you want to filter the first expression using some relationship defined by the second one? I am still trying to understand the original question. Could you describe the basic business problem in words?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

gosi75Business Intelligence ConsultantAuthor Commented:
I'll try to clarify the problem. I need to create a calculated member with the following criteria:

The [DIM Bus Post Group] should be only with code A and as there are so many customer numbers that are empty(and is therefore marked 0000 in the OLAP), I wanted to make the calculated member exclude the customer with 0000. Thats why I was trying to take all of the customer and subtract it with the one marked 0000.

Hope this helps understanding my problem
0
agandauCommented:
When you say that you want to take all of the customers and subtract 0000 you're on the right track.  Subtract the one you want to exclude from the all member.  This approach avoids summing all of the non-0000 customers at query runtime, and instead uses a simple difference between two [hopefully] already aggregated members.

Again, you're on the right track but do it in two steps.  I suggest you form an alternative All member from the Cust Num attribute.  If you're doing it in a client-side query it will look like this:

WITH MEMBER [DIM Customer].[Cust Num].[All minus 0000] AS
[Dim Customer].[Cust Num].[All] - [DIM Customer].[Cust Num].&[0000]

Otherwise just put it in the MDX script (calculated members in BIDS).

The tuple you mentioned in the original question becomes:
([DIM Bus Post Group].[Tegund].&[A],[DIM Customer].[Cust Num].[All minus 0000])

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Megan BrooksSQL Server ConsultantCommented:
I created a similar example (see snippet below) using one of my cubes. I used sub-selects and didn't need a calculated member. The "Southern California" member corresponds to your "A" member -- only data from that region--and is used to restrict the inner sub-select. The "Consortium" set, corresponding to your
[DIM Bus Post Group], is filtered (using Except()) to exclude key "0,". The zero key value represents "None" in the dimension table.
Since everything is filtered in the sub-selects all I have to do is place the measure of interest on columns and the hierarchy of interest on rows. I intentionally omitted the All member in the rows set.
Because the two sub-selects refer to different dimensions, I also need the Exists in the row query to limit the Consortium members to those rows to those that relate to the measure group data. Otherwise the query returns rows with null measure values.

select [Measures].[QI Survey Count] on columns,
       Exists([QI Info].[Consortium].[Consortium], [Measures].[QI Survey Count], "QI Measures") on rows
from (
    select [QI Info].[Consortium].[Consortium] - [QI Info].[Consortium].&[0] on columns from (
       select [Geography].[Region].&[1] on columns from [QI Data]
    )
)

Open in new window

0
Megan BrooksSQL Server ConsultantCommented:
Oops, region 1 is Southern California. The orginal version of my query used a different dimension, in which the region key was a string and you could actually read what it meant.
0
gosi75Business Intelligence ConsultantAuthor Commented:
This one worked, thanks a lot for the assist.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.