I am trying to count rows(Postal codes per State) using a sub query... Please help me to understand the following behavior. MDX:
WITH
SET [rows] AS
{[Customer].[Postal Code].members}
MEMBER [Measures].[RowsCount] AS
Count
(
[rows]
)
MEMBER [Measures].[RowsCount1] AS
Count
(
{[Customer].[Postal Code].members}
)
SELECT
{
[Measures].[RowsCount]
,[Measures].[RowsCount1]
} ON columns
FROM
(
SELECT
(
{[Customer].[State Province Name].&[Hamburg]}
) ON Columns
FROM [Analysis Services Tutorial]
)
EDIT
The following statement would be a solution:
MEMBER [Measures].[RowsCount1] AS
Count
(
{[Customer].[Postal Code].members} * {[Customer].[State Province Name].&[Hamburg]}
)
however I would like to achieve it by using a CurrentMember
function, something like this (does not work):
MEMBER [Measures].[RowsCount1] AS
Count
(
{[Customer].[Postal Code].members} * {[Customer].[State Province Name].CurrentMember}
)
A SUBSELECT
in mdx
isn't the same as a SUBQUERY
in sql - its not always a full filter in the way a subquery is - hence the difference in your results.
But using AdvWrks I'm having difficulty replicating the behaviour you're reporting.
I suspect you could amend your script to one of the following to get your desired result
MEMBER [Measures].[RowsCount1] AS
Count
(
[DIM bla].[HIER bla].[Level]
*
{[DIM bla2].[HIER bla2].&[test]}
)
Or instead of test
use the All member:
MEMBER [Measures].[RowsCount1] AS
Count
(
[DIM bla].[HIER bla].[Level]
*
{[DIM bla2].[HIER bla2].[All]}
)