SSAS MDX 查询中的多个维度条件不起作用

Multiple dimensions conditions in SSAS MDX query not working

我的 SSAS 立方体中有以下数据。

My need is to get the value of the measure based on two conditions with two different dimensions using the MDX.

In this example data, I need to get the Reseller Sales Amount value where the value of Title dimension is equal to Sales Representative and the value of the Genderdimension is equal to Male condition.

我已尝试使用 MDX 中可用的 Case statement and IIF() 函数来实现要求,但它不起作用。

请找到我用不同函数尝试过的查询。

使用 Case 语句:

WITH MEMBER [Measures].[Expression1] AS
CASE WHEN [Employee].[Title].CURRENTMEMBER.MEMBERVALUE = "Sales Representative" THEN (CASE
WHEN [Employee].[Gender].CURRENTMEMBER.MEMBERVALUE = "Male"
THEN [Measures].[Reseller Sales Amount] ELSE 0 END)ELSE 0 END select [Measures].[Expression1] on Columns from [Sales Targets]

使用 IIF() 函数:

WITH MEMBER [Measures].[Expression1] AS
IIF( [Employee].[Title].CURRENTMEMBER.MEMBERVALUE = "Sales Representative" AND [Employee].[Gender].CURRENTMEMBER.MEMBERVALUE = "Male",
[Measures].[Reseller Sales Amount], 0)
SELECT{
[Measures].[Expression1]} ON COLUMNS FROM [Sales Targets] CELL PROPERTIES VALUE, FORMATTED_VALUE, FORMAT_STRING

我得到的两个查询的结果都是 0。

Can anyone please guide me to get the proper result using MDX?

您可以直接在计算的度量中使用 Tuple

WITH MEMBER [Measures].[Expression1] AS
([Measures].[Reseller Sales Amount], [Employee].[Title].[Sales Representative], [Employee].[Gender].[Male])
select [Measures].[Expression1] on Columns 
from [Sales Targets]

或者,如果您希望元组应用于查询中的所有单元格,您可以将元组放在 where 子句中:

Select [Measures].[Reseller Sales Amount] on Columns 
from [Sales Targets]
where ([Employee].[Title].[Sales Representative], [Employee].[Gender].[Male])