Dynamic Filtring in mdx Queries

Radi Soufan 1 Reputation point
2020-08-17T11:59:47.113+00:00

hello...
I need to deal with MDX query in SSAS tabular Server...
That went almost ok with measures with summation
but this is not ok if I decided to work with measures that Deal with Averages.. Since the average calculation is already defined in the model
.. but if you use it in mdx query then you must aggregate for totals.. such as sum(average) or average(average)..
is there a way that I can build an mdx query with dynamic total... without any aggregations.... this is my query

WITH
MEMBER [Measures].[MALES] AS
(
[DIM_GENDER].[DIM_DESC_EN].&[MALE]
,[Measures].[Total Persons]
)
MEMBER [Measures].[FEMALES] AS
(
[DIM_GENDER].[DIM_DESC_EN].&[FEMALE]
,[Measures].[Total Persons]
)
MEMBER [Measures].[TOTALS] AS
Sum
(
{
[DIM_GENDER].[DIM_DESC_EN].&[MALE]
,[DIM_GENDER].[DIM_DESC_EN].&[FEMALE]
}
,[Measures].[Total Persons]
)
MEMBER [DIM_NATIONALITY].[SHORT_NATIONALITY].[TOTAL] AS
Aggregate
(
{
[DIM_NATIONALITY].[SHORT_NATIONALITY].&[US]
,[DIM_NATIONALITY].[SHORT_NATIONALITY].&[NOT US]
}
)
SELECT
NON EMPTY
{
[Measures].[MALES]
,[Measures].[FEMALES]
,[Measures].[TOTALS]
} ON COLUMNS
,NON EMPTY
Union
(
{
[DIM_NATIONALITY].[SHORT_NATIONALITY].[SHORT_NATIONALITY].MEMBERS
}
,[DIM_NATIONALITY].[SHORT_NATIONALITY].[TOTALS]
) ON ROWS
FROM [Model];

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,291 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Lukas Yu -MSFT 5,821 Reputation points
    2020-08-18T06:57:44.977+00:00

    Hi,
    It is not totally clear what your requirement is for the average that "without aggregation?"
    I guess you are expecting to calculate average without summation ?
    I think you could use Avg() function of MDX. You could check examples and specifics in the doc : MDX-Avg
    This function is directly calculate averages with respect to given set.
    Regards,
    Lukas

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.