I want to make calculation in olap cube in ssas. This will be "avg sku by outlets".
There is my expression:
CREATE
MEMBER CURRENTCUBE.[Measures].[Avg Prod Art Id Distinct Count By OldcID] AS
Avg
(
Descendants
(
[dimOutlets].[OLDC ID].CurrentMember
,[dimOutlets].[OLDC ID].[OLDC ID]
)
,[Measures].[Prod Art Id Distinct Count]
);
It works fine, but when I tried to add some logic to it and something went wrong. I want to filter some docs by status or type.
This is what I did:
CREATE
MEMBER CURRENTCUBE.[Measures].[test Calculated Member] AS
Avg
(
NonEmpty
(
NonEmpty
(
{
[dimInvoice].[Doc Type].&[0]
,[dimInvoice].[Doc Type].&[1]
,[dimInvoice].[Doc Type].&[2]
,[dimInvoice].[Doc Type].&[3]
,[dimInvoice].[Doc Type].&[7]
,[dimInvoice].[Doc Type].[All].UnknownMember
}
,{
[dimInvoice].[Status].&[1]
,[dimInvoice].[Status].&[2]
,[dimInvoice].[Status].&[3]
,[dimInvoice].[Status].&[4]
,[dimInvoice].[Status].[All].UnknownMember
}
)
,Descendants
(
[dimOutlets].[OLDC ID].CurrentMember
,[dimOutlets].[OLDC ID].[OLDC ID]
)
)
,[Measures].[Prod Art Id Distinct Count]
) ;
When I try to test this on browser in visual studio, it thinks for a long time and I do not receive a reply.
Is there a best and fast way to do this?
PS. Sorry about my English.
Maybe move the set out into a named set:
CREATE
SET CURRENTCUBE.[DocTypes] AS
NonEmpty
(
NonEmpty
(
{
[dimInvoice].[Doc Type].&[0]
,[dimInvoice].[Doc Type].&[1]
,[dimInvoice].[Doc Type].&[2]
,[dimInvoice].[Doc Type].&[3]
,[dimInvoice].[Doc Type].&[7]
,[dimInvoice].[Doc Type].[All].UnknownMember
}
,{
[dimInvoice].[Status].&[1]
,[dimInvoice].[Status].&[2]
,[dimInvoice].[Status].&[3]
,[dimInvoice].[Status].&[4]
,[dimInvoice].[Status].[All].UnknownMember
}
)
,Descendants
(
[dimOutlets].[OLDC ID].CurrentMember
,[dimOutlets].[OLDC ID].[OLDC ID]
)
);
CREATE
MEMBER CURRENTCUBE.[Measures].[test Calculated Member] AS
Avg
(
[DocTypes]
,[Measures].[Prod Art Id Distinct Count]
) ;